diff options
Diffstat (limited to 'consensus/dummy/consensus.go')
-rw-r--r-- | consensus/dummy/consensus.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index 6b03844..0086581 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -17,7 +17,16 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) +type ConsensusCallbacks struct { + OnSeal func(*types.Block) +} + type DummyEngine struct { + cb *ConsensusCallbacks +} + +func NewDummyEngine(cb *ConsensusCallbacks) *DummyEngine { + return &DummyEngine { cb: cb } } var ( @@ -192,8 +201,9 @@ uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { } func (self *DummyEngine) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { - //time.Sleep(1000 * time.Millisecond) - fmt.Printf("sealed %s\n", block.ParentHash().String()) + if self.cb.OnSeal != nil { + self.cb.OnSeal(block) + } results <- block return nil } |