From a96fc7a942fb6f0a9da5b5bf9c84a98af42a24dc Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 26 Sep 2019 16:16:56 -0400 Subject: remove 1s limit from block generation; more API --- consensus/dummy/consensus.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'consensus/dummy') diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index 0fbc674..c9bbb90 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -8,6 +8,7 @@ import ( "runtime" "time" + myparams "github.com/ava-labs/coreth/params" "github.com/ava-labs/go-ethereum/common" "github.com/ava-labs/go-ethereum/consensus" "github.com/ava-labs/go-ethereum/core/state" @@ -24,6 +25,7 @@ type OnAPIsCallbackType = func(consensus.ChainReader) []rpc.API type ConsensusCallbacks struct { OnSeal func(*types.Block) error + OnSealHash func(*types.Header) OnAPIs OnAPIsCallbackType OnFinalize OnFinalizeCallbackType OnFinalizeAndAssemble OnFinalizeAndAssembleCallbackType @@ -54,8 +56,8 @@ var ( // modified from consensus.go func (self *DummyEngine) verifyHeader(chain consensus.ChainReader, header, parent *types.Header, uncle bool, seal bool) error { // Ensure that the header's extra-data section is of a reasonable size - if uint64(len(header.Extra)) > params.MaximumExtraDataSize { - return fmt.Errorf("extra-data too long: %d > %d", len(header.Extra), params.MaximumExtraDataSize) + if uint64(len(header.Extra)) > myparams.MaximumExtraDataSize { + return fmt.Errorf("extra-data too long: %d > %d", len(header.Extra), myparams.MaximumExtraDataSize) } // Verify the header's timestamp if !uncle { @@ -63,7 +65,8 @@ func (self *DummyEngine) verifyHeader(chain consensus.ChainReader, header, paren return consensus.ErrFutureBlock } } - if header.Time <= parent.Time { + //if header.Time <= parent.Time { + if header.Time < parent.Time { return errZeroBlockTime } // Verify that the gas limit is <= 2^63-1 @@ -278,6 +281,10 @@ func (self *DummyEngine) Seal(chain consensus.ChainReader, block *types.Block, r } func (self *DummyEngine) SealHash(header *types.Header) (hash common.Hash) { + if self.cb.OnSealHash != nil { + self.cb.OnSealHash(header) + } + hasher := sha3.NewLegacyKeccak256() rlp.Encode(hasher, []interface{}{ -- cgit v1.2.3-70-g09d2