Versions in this module Expand all Collapse all v1 v1.0.0 Jan 14, 2021 Changes in this version type BlockChain + func (bc *BlockChain) LookBackVldReaderForRound(r uint64, isCert bool) (state.ValidatorReader, error) v0 v0.10.2 Oct 12, 2020 v0.10.1 Oct 11, 2020 v0.10.0 Sep 16, 2020 Changes in this version type ChainIndexerChain + IsLight func() bool type MessageContext + Recorder local.DetailRecorder v0.9.9 Jun 22, 2020 v0.9.8 Jun 2, 2020 v0.9.7 May 31, 2020 v0.9.6 May 20, 2020 v0.9.5 May 20, 2020 Changes in this version + const ChainSyncFailed + const ChainSyncFinish + const ChainSyncStart + var BloomTrieTablePrefix = "blt-" + var ChtTablePrefix = "cht-" + var DefaultTxPoolConfig = TxPoolConfig + var ErrBlacklistedHash = errors.New("blacklisted hash") + var ErrCancelled = errors.New("cancelled") + var ErrGasLimit = errors.New("exceeds block gas limit") + var ErrGasLimitReached = errors.New("gas limit reached") + var ErrGenesisNoNetworkId = errors.New("genesis has no networkId") + var ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") + var ErrIntrinsicGas = errors.New("intrinsic gas too low") + var ErrInvalidSender = errors.New("invalid sender") + var ErrKnownBlock = errors.New("block already known") + 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 ErrUnderpriced = errors.New("transaction underpriced") + func BuildTemporaryCHT(t *trie.Trie, headers []*types.Header) common.Hash + func CalcGasLimit(parent *types.Block) uint64 + func CanTransfer(db vm.StateDB, addr common.Address, amount *big.Int) bool + func CombineVMConfig(yp *params.YouParams, lcfg vm.LocalConfig) *vm.Config + func GenerateChain(parent *types.Block, engine consensus.Engine, db youdb.Database, n int, ...) ([]*types.Block, []types.Receipts) + func GetHashFn(ref *types.Header, chain ChainContext) func(n uint64) common.Hash + func IntrinsicGas(basicGas uint64, data []byte) (uint64, error) + func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author common.Address) vm.Context + func PrepareVMConfig(ctx ChainContext, round uint64, lcfg vm.LocalConfig) (*vm.Config, error) + func ProcessSenders(txs []*types.Transaction, signer types.Signer) + func ProcessYouVersionState(prev, curr *types.Header) error + func ResetStakingTrieOnNewPeriod(frequency, currentRound uint64, state *state.StateDB) + func SetupGenesisBlock(db youdb.Database, networkId uint64, genesis *Genesis) (gh common.Hash, err error) + func StakingRootForNewBlock(frequency uint64, parent *types.Header) common.Hash + func Transfer(db vm.StateDB, sender, recipient common.Address, amount *big.Int) + func VerifyYouVersionState(prev, curr *types.Header) (err error) + type BlockChain struct + func NewBlockChain(db youdb.Database, engine consensus.Engine, eventMux *event.TypeMux) (*BlockChain, error) + func NewBlockChainWithType(db youdb.Database, engine consensus.Engine, eventMux *event.TypeMux, ...) (*BlockChain, error) + func (bc *BlockChain) BadBlocks() []*types.Block + func (bc *BlockChain) BloomStatus() (uint64, uint64) + func (bc *BlockChain) BltTrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) ChtTrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) CurrentBlock() *types.Block + func (bc *BlockChain) CurrentHeader() *types.Header + func (bc *BlockChain) Engine() consensus.Engine + func (bc *BlockChain) FullOriginBlockNumber() *big.Int + func (bc *BlockChain) Genesis() *types.Block + func (bc *BlockChain) GetAcReader() rawdb.AcReader + 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) GetBlockNumber(hash common.Hash) *uint64 + func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue + func (bc *BlockChain) GetChtBuilder() ChtBuilder + func (bc *BlockChain) GetHashFromCht(headerNum uint64) (common.Hash, error) + 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) GetLightStartHeader() *types.Header + func (bc *BlockChain) GetReceiptsByHash(hash common.Hash) types.Receipts + func (bc *BlockChain) GetVMConfig() *vm.LocalConfig + func (bc *BlockChain) GetVldReader(valRoot common.Hash) (state.ValidatorReader, error) + 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) error + func (bc *BlockChain) InsertGuaranteedHeaderChain(chain []*types.Header) (int, error) + func (bc *BlockChain) InsertHeaderChain(chain []*types.Header) (int, error) + func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain []types.Receipts, postEvent bool) (int, error) + func (bc *BlockChain) IsLight() bool + func (bc *BlockChain) IsUcon() bool + func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) + func (bc *BlockChain) Processor() Processor + func (bc *BlockChain) Reset() error + func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error + func (bc *BlockChain) SetHead(head uint64) error + func (bc *BlockChain) SetProcessor(processor Processor) + func (bc *BlockChain) SetValidator(validator Validator) + func (bc *BlockChain) SetVldFetcher(fetcher VldFetcher) + func (bc *BlockChain) Start() + func (bc *BlockChain) State() (*state.StateDB, error) + func (bc *BlockChain) StateAt(root, valRoot, stakingRoot common.Hash) (*state.StateDB, error) + func (bc *BlockChain) StateTrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) Stop() + func (bc *BlockChain) SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription + func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription + func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription + func (bc *BlockChain) SubscribeNewMinedBlockEvent(ch chan NewMinedBlockEvent) event.Subscription + func (bc *BlockChain) SubscribeRemovedLogsEvent(ch chan<- RemovedLogsEvent) event.Subscription + func (bc *BlockChain) TrieBackingDb(kind types.TrieKind) youdb.Database + func (bc *BlockChain) UconLookBackParams() (seedLookBack, stakeLookBack uint64) + func (bc *BlockChain) UpdateExistedHeader(header *types.Header) + func (bc *BlockChain) UpdateTrustedBlt(acHeader *types.Header) error + func (bc *BlockChain) UpdateTrustedCht(acHeader *types.Header) error + func (bc *BlockChain) Validator() Validator + func (bc *BlockChain) VerifyAcHeader(header *types.Header, verifiedAcParents []*types.Header) error + func (bc *BlockChain) VerifyYouVersionState(chain types.Blocks) (int, error) + func (bc *BlockChain) VerifyYouVersionState2(chain []*types.Header) (int, error) + func (bc *BlockChain) VersionForRound(r uint64) (*params.YouParams, error) + func (bc *BlockChain) VersionForRoundWithParents(r uint64, parents []*types.Header) (*params.YouParams, error) + func (bc *BlockChain) VldTrieNode(hash common.Hash) ([]byte, error) + func (bc *BlockChain) WriteBlockWithState(block *types.Block, state *state.StateDB, receipts []*types.Receipt) error + func (bc *BlockChain) WriteBlockWithoutState(block *types.Block) error + type BlockChainState interface + GetAcReader func() rawdb.AcReader + GetChtBuilder func() ChtBuilder + GetHeaderByNumber func(number uint64) *types.Header + HasBlock func(hash common.Hash, number uint64) bool + HasBlockAndState func(hash common.Hash, number uint64) bool + type BlockGen struct + func (b *BlockGen) AddTx(tx *types.Transaction) + func (b *BlockGen) AddTxWithChain(bc ChainContext, tx *types.Transaction) + func (b *BlockGen) Header() *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) Receipts() []*types.Receipt + func (b *BlockGen) SetCoinbase(addr common.Address) + func (b *BlockGen) SetExtra(data []byte) + func (b *BlockGen) Statedb() *state.StateDB + func (b *BlockGen) TxNonce(addr common.Address) uint64 + type BlockHookFn func(chain vm.ChainReader, header *types.Header, state *state.StateDB, seal bool) (*types.Receipt, []byte, error) + type BlockValidator struct + func NewBlockValidator(blockChain BlockChainState) *BlockValidator + func (v *BlockValidator) ValidateACoCHT(headers []*types.Header, block *types.Block, index int, isNeedBuildTemp bool) error + func (v *BlockValidator) ValidateBody(block *types.Block) error + func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, ...) error + type BloomWithTrieIndexer struct + func (b *BloomWithTrieIndexer) Commit() error + func (b *BloomWithTrieIndexer) Process(ctx context.Context, header *types.Header) error + func (b *BloomWithTrieIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error + func (b *BloomWithTrieIndexer) TrieDB() *trie.Database + type ChainContext interface + GetHeader func(common.Hash, uint64) *types.Header + VersionForRound func(round uint64) (*params.YouParams, error) + type ChainEvent struct + Block *types.Block + Hash common.Hash + Logs []*types.Log + type ChainHeadEvent struct + Block *types.Block + type ChainIndexer struct + func NewBloomWithTrieIndexer(db youdb.Database, fetcher MissingNodesFetcher, size, confirms uint64) *ChainIndexer + func NewChainIndexer(chainDb, indexDb youdb.Database, backend ChainIndexerBackend, ...) *ChainIndexer + func NewChtIndexer(db youdb.Database, fetcher MissingNodesFetcher, size, confirms uint64) *ChainIndexer + 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) + func (c *ChainIndexer) UpdateSection(section uint64, shead common.Hash) error + type ChainIndexerBackend interface + Commit func() error + Process func(ctx context.Context, header *types.Header) error + Reset func(ctx context.Context, section uint64, prevHead common.Hash) error + type ChainIndexerChain interface + CurrentHeader func() *types.Header + SubscribeChainHeadEvent func(ch chan<- ChainHeadEvent) event.Subscription + type ChainSyncEvent struct + Type ChainSyncType + type ChainSyncType int + type ChtBuilder interface + GetCopiedCHT func() (t *trie.Trie, headNum uint64) + type ChtIndexerBackend struct + func NewChtBackend(db youdb.Database, fetcher MissingNodesFetcher, size, confirms uint64) *ChtIndexerBackend + func (c *ChtIndexerBackend) Commit() error + func (c *ChtIndexerBackend) GetCopiedCHT() (t *trie.Trie, headNum uint64) + func (c *ChtIndexerBackend) GetValue(headerNum uint64) ([]byte, error) + func (c *ChtIndexerBackend) Process(ctx context.Context, header *types.Header) error + func (c *ChtIndexerBackend) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error + func (c *ChtIndexerBackend) TrieDB() *trie.Database + type DefaultConverter struct + func (d *DefaultConverter) ApplyMessage(msgCtx *MessageContext) (ret []byte, usedGas uint64, failed bool, err error) + func (d *DefaultConverter) IntrinsicGas(data []byte, to *common.Address) (uint64, error) + type DeleteBlockContentCallback func(youdb.Deleter, common.Hash, uint64) + type DumpAllTx struct + Pending DumpTransaction + Queue DumpTransaction + type DumpList struct + Transaction map[uint64]DumpTxdata + type DumpTransaction struct + TxList map[string]DumpList + type DumpTxdata struct + AccountNonce uint64 + Amount *big.Int + GasLimit uint64 + Hash common.Hash + Payload []byte + Price *big.Int + R string + Recipient *common.Address + S string + V string + 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 GenesisAlloc + Coinbase common.Address + Consensus []byte + CurrVersion params.YouVersion + ExtraData []byte + GasLimit uint64 + GasUsed uint64 + Mixhash common.Hash + NetworkId uint64 + Number uint64 + ParentHash common.Hash + Timestamp uint64 + Validators GenesisValidators + func DefaultGenesisBlock() *Genesis + func DefaultTestNetGenesisBlock() *Genesis + func (g *Genesis) Commit(db youdb.Database) (*types.Block, error) + func (g *Genesis) MustCommit(db youdb.Database) *types.Block + func (g *Genesis) PreCheck() error + func (g *Genesis) ToBlock(db youdb.Database) *types.Block + func (g *Genesis) UnmarshalJSON(input []byte) error + func (g Genesis) MarshalJSON() ([]byte, error) + type GenesisAccount struct + Balance *big.Int + Code []byte + Nonce uint64 + Storage map[common.Hash]common.Hash + func (g *GenesisAccount) UnmarshalJSON(input []byte) error + func (g GenesisAccount) MarshalJSON() ([]byte, error) + type GenesisAlloc map[common.Address]GenesisAccount + func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error + type GenesisMismatchError struct + New common.Hash + Stored common.Hash + func (e *GenesisMismatchError) Error() string + type GenesisValidator struct + BlsPubKey hexutil.Bytes + Coinbase common.Address + MainPubKey hexutil.Bytes + Name string + OperatorAddress common.Address + Role params.ValidatorRole + Status uint8 + Token *big.Int + func (g *GenesisValidator) UnmarshalJSON(input []byte) error + func (g GenesisValidator) MarshalJSON() ([]byte, error) + type GenesisValidators map[common.Address]GenesisValidator + func (gv *GenesisValidators) UnmarshalJSON(data []byte) error + type HeaderChain struct + func NewHeaderChain(chainDb youdb.Database, parent *BlockChain, engine consensus.Engine, ...) (*HeaderChain, error) + func (hc *HeaderChain) CurrentHeader() *types.Header + func (hc *HeaderChain) Engine() consensus.Engine + func (hc *HeaderChain) GetAcReader() rawdb.AcReader + func (hc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) + func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block + func (hc *HeaderChain) GetBlockByNumber(number uint64) *types.Block + func (hc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash + func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 + func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash + func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header + func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header + func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header + func (hc *HeaderChain) GetLightStartHeader() *types.Header + func (hc *HeaderChain) GetVldReader(valRoot common.Hash) (state.ValidatorReader, error) + func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool + func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader WhCallback, start time.Time) (int, error) + func (hc *HeaderChain) SetCurrentHeader(head *types.Header) + func (hc *HeaderChain) SetGenesis(head *types.Header) + func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, ...) + func (hc *HeaderChain) SetLightStartHeader(head *types.Header) + func (hc *HeaderChain) UpdateExistedHeader(header *types.Header) + func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, seals []bool) (int, error) + func (hc *HeaderChain) VersionForRound(r uint64) (*params.YouParams, error) + func (hc *HeaderChain) VersionForRoundWithParents(r uint64, parents []*types.Header) (*params.YouParams, error) + func (hc *HeaderChain) WriteHeader(header *types.Header) error + type IRouter interface + AddEndBlockHook func(name string, fn BlockHookFn) + AddTxConverter func(modelAddr common.Address, converter TxConverter) + GetConverter func(msgToAddr *common.Address) TxConverter + type InsertBlockEvent struct + Block *types.Block + type Message interface + CheckNonce func() bool + Data func() []byte + From func() common.Address + Gas func() uint64 + GasPrice func() *big.Int + Nonce func() uint64 + To func() *common.Address + TxHash func() common.Hash + Value func() *big.Int + type MessageContext struct + AvailableGas uint64 + Cfg *vm.Config + Chain ChainContext + Coinbase common.Address + GP *GasPool + Header *types.Header + InitialGas uint64 + Msg Message + State *state.StateDB + func NewMsgContext(msg Message, statedb *state.StateDB, bc ChainContext, header *types.Header, ...) *MessageContext + func (mc *MessageContext) GasUsed() uint64 + func (mc *MessageContext) UseGas(amount uint64) error + type MissingNodesFetcher interface + FetchMissingNodes func(ctx context.Context, trie *trie.Trie, trieTable youdb.Database, section uint64, ...) error + type NewMinedBlockEvent struct + Block *types.Block + type NewTxsEvent struct + Txs []*types.Transaction + type PendingLogsEvent struct + Logs []*types.Log + type Processor interface + ApplyMessageEntry func(msg Message, statedb *state.StateDB, bc ChainContext, header *types.Header, ...) ([]byte, uint64, bool, error) + ApplyTransaction func(tx *types.Transaction, signer types.Signer, statedb *state.StateDB, ...) (*types.Receipt, uint64, error) + EndBlock func(chain vm.ChainReader, header *types.Header, state *state.StateDB, isSeal bool) ([]*types.Receipt, [][]byte, []error) + Process func(yp *params.YouParams, block *types.Block, statedb *state.StateDB, ...) (types.Receipts, []*types.Log, uint64, error) + type RemovedLogsEvent struct + Logs []*types.Log + type StateProcessor struct + func NewStateProcessor(bc *BlockChain, engine consensus.Engine) *StateProcessor + func (p *StateProcessor) AddEndBlockHook(name string, fn BlockHookFn) + func (p *StateProcessor) AddTxConverter(modelAddr common.Address, converter TxConverter) + func (p *StateProcessor) ApplyMessageEntry(msg Message, statedb *state.StateDB, bc ChainContext, header *types.Header, ...) ([]byte, uint64, bool, error) + func (p *StateProcessor) ApplyTransaction(tx *types.Transaction, signer types.Signer, statedb *state.StateDB, ...) (*types.Receipt, uint64, error) + func (p *StateProcessor) EndBlock(chain vm.ChainReader, header *types.Header, state *state.StateDB, isSeal bool) ([]*types.Receipt, [][]byte, []error) + func (p *StateProcessor) GetConverter(msgToAddr *common.Address) TxConverter + func (p *StateProcessor) Process(yp *params.YouParams, block *types.Block, statedb *state.StateDB, ...) (types.Receipts, []*types.Log, uint64, error) + type StateTransition struct + func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bool, err error) + type TxConverter interface + ApplyMessage func(msgCtx *MessageContext) ([]byte, uint64, bool, error) + IntrinsicGas func(data []byte, to *common.Address) (uint64, error) + type TxPool struct + func NewTxPool(config TxPoolConfig, 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.Transactions) []error + func (pool *TxPool) AddRemotesSync(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) Locals() []common.Address + func (pool *TxPool) Nonce(addr common.Address) uint64 + func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) + func (pool *TxPool) RawDump(queue map[common.Address]*txList) DumpTransaction + func (pool *TxPool) SetGasPrice(price *big.Int) + func (pool *TxPool) Stats() (int, int) + func (pool *TxPool) Status(hashes []common.Hash) []TxStatus + func (pool *TxPool) Stop() + func (pool *TxPool) SubscribeNewTxsEvent(ch chan<- NewTxsEvent) event.Subscription + func (pool *TxPool) TransactionsNumber() (int, int) + type TxPoolConfig struct + AccountQueue uint64 + AccountSlots uint64 + GlobalQueue uint64 + GlobalSlots uint64 + Journal string + Lifetime time.Duration + Locals []common.Address + NoLocals bool + PriceBump uint64 + PriceLimit uint64 + Rejournal time.Duration + type TxStatus uint + const TxStatusIncluded + const TxStatusPending + const TxStatusQueued + const TxStatusUnknown + type UpdateHeadBlocksCallback func(youdb.Putter, *types.Header) + type Validator interface + ValidateACoCHT func(headers []*types.Header, block *types.Block, index int, isNeedBuildTemp bool) error + ValidateBody func(block *types.Block) error + ValidateState func(block, parent *types.Block, statedb *state.StateDB, receipts types.Receipts, ...) error + type VldFetcher interface + FetchVldTrie func(root common.Hash) error + type WhCallback func(*types.Header) error