diff options
author | Determinant <[email protected]> | 2019-09-26 16:16:56 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-09-26 16:16:56 -0400 |
commit | a96fc7a942fb6f0a9da5b5bf9c84a98af42a24dc (patch) | |
tree | 8cb685aa6df55f15758e93ffe24b6c5d075859a5 /consensus | |
parent | 2e0b38c332a3ab4e11b97a38ff6d8427a3d96215 (diff) |
remove 1s limit from block generation; more API
Diffstat (limited to 'consensus')
-rw-r--r-- | consensus/dummy/consensus.go | 13 |
1 files changed, 10 insertions, 3 deletions
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{}{ |