erigon-pulse/consensus/result.go
Alex Sharov 0be3044b7e
rename (#1978)
* rename

* rename "make grpc"

* rename "abi bindings templates"

* rename "abi bindings templates"
2021-05-20 19:25:53 +01:00

43 lines
717 B
Go

package consensus
import (
"context"
"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/log"
)
type ResultWithContext struct {
Cancel
*types.Block
}
type Cancel struct {
context.Context
cancel context.CancelFunc
}
func (c *Cancel) CancelFunc() {
log.Debug("cancel mining task", "callers", debug.Callers(10))
c.cancel()
}
func NewCancel(ctxs ...context.Context) Cancel {
var ctx context.Context
if len(ctxs) > 0 {
ctx = ctxs[0]
} else {
ctx = context.Background()
}
ctx, cancelFn := context.WithCancel(ctx)
return Cancel{ctx, cancelFn}
}
func StabCancel() Cancel {
return Cancel{
context.Background(),
func() {},
}
}