Versions in this module Expand all Collapse all v1 v1.1.3 Feb 13, 2020 Changes in this version + const BlockChainVersion + const MinimumGasPrice_local + var BadHashes = map[common.Hash]bool + var DefaultTxPoolConfig = TxPoolConfig + var ErrBlacklistedHash = errors.New("blacklisted hash") + var ErrExceedNumber = errors.New("number exceed specified number") + var ErrGasLimit = errors.New("exceeds block gas limit") + var ErrGasLimitReached = errors.New("gas limit reached") + var ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") + var ErrInsufficientFundsForPayer = errors.New("insufficient funds for gas * price for payer") + var ErrInsufficientFundsForSender = errors.New("insufficient funds for value for sender") + var ErrIntrinsicGas = errors.New("intrinsic gas too low") + var ErrInvalidPayer = errors.New("invalid payer") + var ErrInvalidSender = errors.New("invalid sender") + var ErrIsFallback = errors.New("block and state is falling back") + var ErrKnownBlock = errors.New("block already known") + var ErrNegativeFee = errors.New("negative fee") + var ErrNegativeValue = errors.New("negative value") + var ErrNoGenesis = errors.New("Genesis not found in chain") + var ErrNonceTooHigh = errors.New("nonce too high") + var ErrNonceTooLow = errors.New("nonce too low") + var ErrOversizedData = errors.New("oversized data") + var ErrReplaceUnderpriced = errors.New("replacement transaction underpriced") + var ErrRewardSnailNumberWrong = errors.New("reward snailBlock number is wrong") + var ErrSnailNumberAlreadyRewarded = errors.New("snailBlock number already rewarded") + var ErrSnailNumberRewardTooFast = errors.New("snailBlock number reward too fast") + var ErrSnailNumberRewardTooSlow = errors.New("snailBlock number reward too slow") + var ErrUnderpriced = errors.New("transaction underpriced") + func ApplyMessage(evm *vm.EVM, msg Message, gp *GasPool) ([]byte, uint64, bool, error) + func ApplyTransaction(config *params.ChainConfig, bc ChainContext, gp *GasPool, ...) (*types.Receipt, uint64, error) + func CanTransfer(db vm.StateDB, addr common.Address, amount *big.Int) bool + func FastCalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64 + func GenerateChain(config *params.ChainConfig, parent *types.Block, engine consensus.Engine, ...) ([]*types.Block, []types.Receipts) + func GenerateChainWithReward(config *params.ChainConfig, parent *types.Block, ...) ([]*types.Block, []types.Receipts) + func GenesisFastBlockForTesting(db etruedb.Database, addr common.Address, balance *big.Int) *types.Block + func GenesisSnailBlockForTesting(db etruedb.Database, addr common.Address, balance *big.Int) *types.SnailBlock + func GetHashFn(ref *types.Header, chain ChainContext) func(n uint64) common.Hash + func IntrinsicGas(data []byte, contractCreation, homestead bool) (uint64, error) + func NewEVMContext(msg Message, header *types.Header, chain ChainContext, difficulty *big.Int, ...) vm.Context + func SetReceiptsData(config *params.ChainConfig, block *types.Block, receipts types.Receipts) error + func SetupGenesisBlock(db etruedb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, common.Hash, error) + func Transfer(db vm.StateDB, sender, recipient common.Address, amount *big.Int) + type BlockChain struct + RewardNumberFeed event.Feed + func NewBlockChain(db etruedb.Database, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, ...) (*BlockChain, error) + func NewCanonical(engine consensus.Engine, n int, full bool) (etruedb.Database, *BlockChain, error) + func (bc *BlockChain) BadBlocks() []*types.Block + func (bc *BlockChain) Config() *params.ChainConfig + func (bc *BlockChain) CurrentBlock() *types.Block + func (bc *BlockChain) CurrentCommitHeight() *big.Int + func (bc *BlockChain) CurrentFastBlock() *types.Block + func (bc *BlockChain) CurrentGcHeight() *big.Int + func (bc *BlockChain) CurrentHeader() *types.Header + func (bc *BlockChain) CurrentLastBlock() *types.Block + func (bc *BlockChain) CurrentReward() *types.BlockReward + func (bc *BlockChain) Engine() consensus.Engine + func (bc *BlockChain) Export(w io.Writer) error + func (bc *BlockChain) ExportN(w io.Writer, first uint64, last uint64) error + func (bc *BlockChain) FastSyncCommitHead(hash common.Hash) error + func (bc *BlockChain) GasLimit() uint64 + func (bc *BlockChain) Genesis() *types.Block + func (bc *BlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) + func (bc *BlockChain) GetBlock(hash common.Hash, number uint64) *types.Block + func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block + func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block + func (bc *BlockChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash + func (bc *BlockChain) GetBlockNumber() uint64 + func (bc *BlockChain) GetBlockReward(snumber uint64) *types.BlockReward + func (bc *BlockChain) GetBody(hash common.Hash) *types.Body + func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue + func (bc *BlockChain) GetHeader(hash common.Hash, number uint64) *types.Header + func (bc *BlockChain) GetHeaderByHash(hash common.Hash) *types.Header + func (bc *BlockChain) GetHeaderByNumber(number uint64) *types.Header + func (bc *BlockChain) GetLastRowByFastCurrentBlock() *types.BlockReward + func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts + func (bc *BlockChain) GetVMConfig() *vm.Config + func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasBlockAndState(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasHeader(hash common.Hash, number uint64) bool + func (bc *BlockChain) HasState(hash common.Hash) bool + func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) + func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) + func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []types.Receipts) (int, error) + func (bc *BlockChain) IsFallback() bool + func (bc *BlockChain) NextSnailNumberReward() *big.Int + func (bc *BlockChain) Processor() Processor + func (bc *BlockChain) Reset() error + func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error + func (bc *BlockChain) Rollback(chain []common.Hash) + func (bc *BlockChain) SetHead(head uint64) error + func (bc *BlockChain) SetProcessor(processor Processor) + func (bc *BlockChain) SetValidator(validator Validator) + func (bc *BlockChain) State() (*state.StateDB, error) + func (bc *BlockChain) StateAt(root common.Hash) (*state.StateDB, error) + func (bc *BlockChain) StateCache() state.Database + func (bc *BlockChain) Stop() + func (bc *BlockChain) SubscribeChainEvent(ch chan<- types.FastChainEvent) event.Subscription + func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- types.FastChainHeadEvent) event.Subscription + func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- types.FastChainSideEvent) event.Subscription + func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription + func (bc *BlockChain) SubscribeRemovedLogsEvent(ch chan<- types.RemovedLogsEvent) event.Subscription + func (bc *BlockChain) TrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) Validator() Validator + func (bc *BlockChain) VerifyHasState(fb *types.Block) bool + func (bc *BlockChain) WriteBlockWithoutState(block *types.Block) (err error) + type BlockGen struct + func (b *BlockGen) AddTx(tx *types.Transaction) + func (b *BlockGen) AddTxWithChain(bc *BlockChain, tx *types.Transaction) + func (b *BlockGen) AddUncheckedReceipt(receipt *types.Receipt) + func (b *BlockGen) AddUncle(h *types.Header) + func (b *BlockGen) Number() *big.Int + func (b *BlockGen) OffsetTime(seconds int64) + func (b *BlockGen) PrevBlock(index int) *types.Block + func (b *BlockGen) SetCoinbase(addr common.Address) + func (b *BlockGen) SetExtra(data []byte) + func (b *BlockGen) SetNonce(nonce types.BlockNonce) + func (b *BlockGen) TxNonce(addr common.Address) uint64 + type BlockValidator struct + func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine) *BlockValidator + func (fv *BlockValidator) ValidateBody(block *types.Block, validateSign bool) error + func (fv *BlockValidator) ValidateState(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, ...) error + type CacheConfig struct + Deleted bool + Disabled bool + HeightGcState atomic.Value + TrieCleanLimit int + TrieNodeLimit int + TrieTimeLimit time.Duration + type ChainContext interface + Engine func() consensus.Engine + GetHeader func(common.Hash, uint64) *types.Header + type ChainIndexer struct + func NewChainIndexer(chainDb, indexDb etruedb.Database, backend ChainIndexerBackend, ...) *ChainIndexer + func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash) + func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) + func (c *ChainIndexer) Close() error + func (c *ChainIndexer) SectionHead(section uint64) common.Hash + func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash) + func (c *ChainIndexer) Start(chain ChainIndexerChain) + type ChainIndexerBackend interface + Commit func() error + Process func(header *types.Header) + Reset func(section uint64, prevHead common.Hash) error + type ChainIndexerChain interface + CurrentHeader func() *types.Header + SubscribeChainEvent func(ch chan<- types.FastChainEvent) event.Subscription + type FastDeleteCallback func(rawdb.DatabaseDeleter, common.Hash, uint64) + type FastWhCallback func(*types.Header) error + type GasPool uint64 + func (gp *GasPool) AddGas(amount uint64) *GasPool + func (gp *GasPool) Gas() uint64 + func (gp *GasPool) String() string + func (gp *GasPool) SubGas(amount uint64) error + type Genesis struct + Alloc types.GenesisAlloc + Coinbase common.Address + Committee []*types.CommitteeMember + Config *params.ChainConfig + Difficulty *big.Int + ExtraData []byte + GasLimit uint64 + GasUsed uint64 + Mixhash common.Hash + Nonce uint64 + Number uint64 + ParentHash common.Hash + Timestamp uint64 + func DefaultDevGenesisBlock() *Genesis + func DefaultGenesisBlock() *Genesis + func DefaultTestnetGenesisBlock() *Genesis + func (g *Genesis) CommitFast(db etruedb.Database) (*types.Block, error) + func (g *Genesis) CommitSnail(db etruedb.Database) (*types.SnailBlock, error) + func (g *Genesis) MustFastCommit(db etruedb.Database) *types.Block + func (g *Genesis) MustSnailCommit(db etruedb.Database) *types.SnailBlock + func (g *Genesis) ToFastBlock(db etruedb.Database) *types.Block + func (g *Genesis) ToSnailBlock(db etruedb.Database) *types.SnailBlock + func (g *Genesis) UnmarshalJSON(input []byte) error + func (g Genesis) MarshalJSON() ([]byte, error) + type GenesisAccount struct + Balance *big.Int + Code []byte + Nonce uint64 + PrivateKey []byte + Storage map[common.Hash]common.Hash + type GenesisMismatchError struct + New common.Hash + Stored common.Hash + func (e *GenesisMismatchError) Error() string + type HeaderChain struct + func NewHeaderChain(chainDb etruedb.Database, config *params.ChainConfig, engine consensus.Engine, ...) (*HeaderChain, error) + func (fhc *HeaderChain) Config() *params.ChainConfig + func (fhc *HeaderChain) CurrentHeader() *types.Header + func (fhc *HeaderChain) Engine() consensus.Engine + func (fhc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) + func (fhc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block + func (fhc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash + func (fhc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header + func (fhc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header + func (fhc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header + func (fhc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool + func (fhc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader FastWhCallback, start time.Time) (int, error) + func (fhc *HeaderChain) SetCurrentHeader(head *types.Header) + func (fhc *HeaderChain) SetGenesis(head *types.Header) + func (fhc *HeaderChain) SetHead(head uint64, delFn FastDeleteCallback) + func (fhc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int) (int, error) + func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 + func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, err error) + type Message interface + CheckNonce func() bool + Data func() []byte + Fee func() *big.Int + From func() common.Address + Gas func() uint64 + GasPrice func() *big.Int + Nonce func() uint64 + Payment func() common.Address + To func() *common.Address + Value func() *big.Int + type Processor interface + Process func(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) + type SnailChain interface + Config func() *params.ChainConfig + CurrentBlock func() *types.SnailBlock + CurrentHeader func() *types.SnailHeader + GetBlock func(hash common.Hash, number uint64) *types.SnailBlock + GetBlockByHash func(hash common.Hash) *types.SnailBlock + GetBlockByNumber func(number uint64) *types.SnailBlock + GetHeader func(hash common.Hash, number uint64) *types.SnailHeader + GetHeaderByHash func(hash common.Hash) *types.SnailHeader + GetHeaderByNumber func(number uint64) *types.SnailHeader + SubscribeChainHeadEvent func(ch chan<- types.SnailChainHeadEvent) event.Subscription + Validator func() SnailValidator + type SnailValidator interface + ValidateBody func(block *types.SnailBlock, verifyFruits bool) error + ValidateFruit func(fruit *types.SnailBlock, headerNumber *big.Int, canonical bool) error + ValidateRewarded func(number uint64, hash common.Hash) error + VerifySnailSeal func(chain consensus.SnailChainReader, header *types.SnailHeader, isFruit bool) error + type StateProcessor struct + func NewStateProcessor(config *params.ChainConfig, bc *BlockChain, engine consensus.Engine) *StateProcessor + func (fp *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg vm.Config) (types.Receipts, []*types.Log, uint64, error) + type StateTransition struct + func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition + func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bool, err error) + type TxPool struct + func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain blockChain) *TxPool + func (pool *TxPool) AddLocal(tx *types.Transaction) error + func (pool *TxPool) AddLocals(txs []*types.Transaction) []error + func (pool *TxPool) AddRemote(tx *types.Transaction) error + func (pool *TxPool) AddRemotes(txs []*types.Transaction) []error + func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) + func (pool *TxPool) GasPrice() *big.Int + func (pool *TxPool) Get(hash common.Hash) *types.Transaction + func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) + func (pool *TxPool) SetGasPrice(price *big.Int) + func (pool *TxPool) State() *state.ManagedState + func (pool *TxPool) Stats() (int, int) + func (pool *TxPool) Status(hashes []common.Hash) []TxStatus + func (pool *TxPool) Stop() + func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- types.NewTxsEvent) event.Subscription + type TxPoolConfig struct + AccountQueue uint64 + AccountSlots uint64 + GlobalQueue uint64 + GlobalSlots uint64 + Journal string + Lifetime time.Duration + NoLocals bool + PriceBump uint64 + PriceLimit uint64 + Rejournal time.Duration + type TxStatus uint + const TxStatusIncluded + const TxStatusPending + const TxStatusQueued + const TxStatusUnknown + type Validator interface + ValidateBody func(block *types.Block, validateSign bool) error + ValidateState func(block, parent *types.Block, state *state.StateDB, receipts types.Receipts, ...) error + type WriteStatus byte + const CanonStatTy + const NonStatTy + const SideStatTy