engine.go 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. package istanbul
  2. import (
  3. "math/big"
  4. "time"
  5. "github.com/ethereum/go-ethereum/common"
  6. "github.com/ethereum/go-ethereum/consensus"
  7. "github.com/ethereum/go-ethereum/core/state"
  8. "github.com/ethereum/go-ethereum/core/types"
  9. )
  10. type Engine interface {
  11. Address() common.Address
  12. Author(header *types.Header) (common.Address, error)
  13. ExtractGenesisValidators(header *types.Header) ([]common.Address, error)
  14. Signers(header *types.Header) ([]common.Address, error)
  15. CommitHeader(header *types.Header, seals [][]byte, round *big.Int) error
  16. VerifyBlockProposal(chain consensus.ChainHeaderReader, block *types.Block, validators ValidatorSet) (time.Duration, error)
  17. VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, parents []*types.Header, validators ValidatorSet) error
  18. VerifyUncles(chain consensus.ChainReader, block *types.Block) error
  19. VerifySeal(chain consensus.ChainHeaderReader, header *types.Header, validators ValidatorSet) error
  20. Prepare(chain consensus.ChainHeaderReader, header *types.Header, validators ValidatorSet) error
  21. Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header)
  22. FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
  23. Seal(chain consensus.ChainHeaderReader, block *types.Block, validators ValidatorSet) (*types.Block, error)
  24. SealHash(header *types.Header) common.Hash
  25. CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int
  26. WriteVote(header *types.Header, candidate common.Address, authorize bool) error
  27. ReadVote(header *types.Header) (candidate common.Address, authorize bool, err error)
  28. }