Versions in this module Expand all Collapse all v1 v1.1.3 Feb 13, 2020 Changes in this version + var BadHashes = map[common.Hash]bool + var DefaultSnailPoolConfig = SnailPoolConfig + var ErrBlacklistedHash = errors.New("blacklisted hash") + var ErrBlockTime = errors.New("invalid block time") + var ErrFruitTime = errors.New("invalid fruit time") + var ErrGapFruits = errors.New("invalid fruits time gap") + var ErrInvalidFast = errors.New("invalid fast hash") + var ErrInvalidFruits = errors.New("invalid fruits number") + var ErrInvalidSignHash = errors.New("invalid sign") + var ErrKnownBlock = errors.New("block already known") + var ErrNoFruits = errors.New("invalid fruits count") + var ErrNoGenesis = errors.New("Genesis not found in chain") + var ErrNotExist = errors.New("not exist") + var ErrRewardedBlock = errors.New("block already rewarded") + func GenerateChain(config *params.ChainConfig, fastChain *core.BlockChain, ...) []*types.SnailBlock + func MakeSnailBlock(chain *SnailBlockChain, fastchain *core.BlockChain, parent *types.SnailBlock, ...) (*types.SnailBlock, error) + func MakeSnailBlockBlockChain(chain *SnailBlockChain, fastchain *core.BlockChain, parent *types.SnailBlock, ...) ([]*types.SnailBlock, error) + func MakeSnailBlockFruit(chain *SnailBlockChain, fastchain *core.BlockChain, makeBlockNum int, ...) (*types.SnailBlock, error) + func MakeSnailBlockFruits(chain *SnailBlockChain, fastchain *core.BlockChain, makeStarblockNumber int, ...) ([]*types.SnailBlock, error) + func MakeSnailBlockFruitsWithoutInsert(chain *SnailBlockChain, fastchain *core.BlockChain, makeStarblockNumber int, ...) ([]*types.SnailBlock, error) + func MakeSnailBlocks(fastchain *core.BlockChain, snailchain *SnailBlockChain, ...) ([]*types.SnailBlock, error) + type BlockGen struct + func (b *BlockGen) AddFruit(block *types.SnailBlock) + func (b *BlockGen) AddUncle(h *types.SnailHeader) + func (b *BlockGen) Number() *big.Int + func (b *BlockGen) OffsetTime(seconds int64) + func (b *BlockGen) PrevBlock(index int) *types.SnailBlock + func (b *BlockGen) SetCoinbase(addr common.Address) + func (b *BlockGen) SetExtra(data []byte) + type BlockValidator struct + func NewBlockValidator(config *params.ChainConfig, fc *core.BlockChain, sc *SnailBlockChain, ...) *BlockValidator + func (v *BlockValidator) ValidateBody(block *types.SnailBlock, verifyFruits bool) error + func (v *BlockValidator) ValidateFruit(fruit *types.SnailBlock, headerNumber *big.Int, canonical bool) error + func (v *BlockValidator) ValidateRewarded(number uint64, hash common.Hash) error + func (v *BlockValidator) VerifySnailSeal(chain consensus.SnailChainReader, header *types.SnailHeader, isFruit bool) error + type ChainIndexer struct + func NewChainIndexer(chainDb, indexDb etruedb.Database, backend ChainIndexerBackend, ...) *ChainIndexer + func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) + func (c *ChainIndexer) AddKnownSectionHead(section uint64, shead common.Hash) + 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 IndexerChain) + func (c *ChainIndexer) StartSnail(chain IndexerChain) + type ChainIndexerBackend interface + Commit func() error + Process func(header *types.SnailHeader) + Reset func(section uint64, prevHead common.Hash) error + type ChainIndexerChain interface + CurrentHeader func() *types.SnailHeader + SubscribeChainEvent func(ch chan<- types.SnailChainEvent) event.Subscription + type DeleteCallback func(rawdb.DatabaseDeleter, common.Hash, uint64) + type HeaderChain struct + func NewHeaderChain(chainDb etruedb.Database, config *params.ChainConfig, engine consensus.Engine, ...) (*HeaderChain, error) + func (hc *HeaderChain) Config() *params.ChainConfig + func (hc *HeaderChain) CurrentHeader() *types.SnailHeader + func (hc *HeaderChain) Engine() consensus.Engine + 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.SnailBlock + func (hc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash + func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 + func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.SnailHeader + func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.SnailHeader + func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.SnailHeader + func (hc *HeaderChain) GetTd(hash common.Hash, number uint64) *big.Int + func (hc *HeaderChain) GetTdByHash(hash common.Hash) *big.Int + func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool + func (hc *HeaderChain) InsertHeaderChain(chain []*types.SnailHeader, writeHeader WhCallback, start time.Time) (int, error) + func (hc *HeaderChain) SetCurrentHeader(head *types.SnailHeader) + func (hc *HeaderChain) SetGenesis(head *types.SnailHeader) + func (hc *HeaderChain) SetHead(head uint64, delFn DeleteCallback) + func (hc *HeaderChain) ValidateHeaderChain(chain []*types.SnailHeader, checkFreq int) (int, error) + func (hc *HeaderChain) WriteHeader(header *types.SnailHeader) (status WriteStatus, err error) + func (hc *HeaderChain) WriteTd(hash common.Hash, number uint64, td *big.Int) error + type IndexerChain interface + CurrentHeader func() *types.SnailHeader + SubscribeChainEvent func(ch chan<- types.SnailChainEvent) event.Subscription + type MakechianConfig struct + DifficultyLevel int + FruitFresh int64 + FruitNumber uint64 + type SnailBlockChain struct + func MakeChain(fastBlockNumbers int, snailBlockNumbers int, genesis *core.Genesis, ...) (*SnailBlockChain, *core.BlockChain) + func MakeSnailChain(snailBlockNumbers int, genesis *core.Genesis, engine consensus.Engine) (*SnailBlockChain, *core.BlockChain) + func NewSnailBlockChain(db etruedb.Database, chainConfig *params.ChainConfig, engine consensus.Engine, ...) (*SnailBlockChain, error) + func (bc *SnailBlockChain) BadBlocks() []*types.SnailBlock + func (bc *SnailBlockChain) Config() *params.ChainConfig + func (bc *SnailBlockChain) CurrentBlock() *types.SnailBlock + func (bc *SnailBlockChain) CurrentFastBlock() *types.SnailBlock + func (bc *SnailBlockChain) CurrentHeader() *types.SnailHeader + func (bc *SnailBlockChain) Engine() consensus.Engine + func (bc *SnailBlockChain) Export(w io.Writer) error + func (bc *SnailBlockChain) ExportN(w io.Writer, first uint64, last uint64) error + func (bc *SnailBlockChain) FastInsertChain(chain types.SnailBlocks) (int, error) + func (bc *SnailBlockChain) Genesis() *types.SnailBlock + func (bc *SnailBlockChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) + func (bc *SnailBlockChain) GetBlock(hash common.Hash, number uint64) *types.SnailBlock + func (bc *SnailBlockChain) GetBlockByHash(hash common.Hash) *types.SnailBlock + func (bc *SnailBlockChain) GetBlockByNumber(number uint64) *types.SnailBlock + func (bc *SnailBlockChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash + func (bc *SnailBlockChain) GetBlocksFromHash(hash common.Hash, n int) (blocks []*types.SnailBlock) + func (bc *SnailBlockChain) GetBlocksFromNumber(fromNumber uint64) (blocks []*types.SnailBlock) + func (bc *SnailBlockChain) GetBody(hash common.Hash) *types.SnailBody + func (bc *SnailBlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue + func (bc *SnailBlockChain) GetDatabase() etruedb.Database + func (bc *SnailBlockChain) GetFruit(fastHash common.Hash) *types.SnailBlock + func (bc *SnailBlockChain) GetFruitByFastHash(fastHash common.Hash) (*types.SnailBlock, uint64) + func (bc *SnailBlockChain) GetFruitsHash(header *types.SnailHeader, fruits []*types.SnailBlock) common.Hash + func (bc *SnailBlockChain) GetHeader(hash common.Hash, number uint64) *types.SnailHeader + func (bc *SnailBlockChain) GetHeaderByHash(hash common.Hash) *types.SnailHeader + func (bc *SnailBlockChain) GetHeaderByNumber(number uint64) *types.SnailHeader + func (bc *SnailBlockChain) GetHeadsFromNumber(fromNumber uint64) (blocks []*types.SnailHeader) + func (bc *SnailBlockChain) GetTd(hash common.Hash, number uint64) *big.Int + func (bc *SnailBlockChain) GetTdByHash(hash common.Hash) *big.Int + func (bc *SnailBlockChain) HasBlock(hash common.Hash, number uint64) bool + func (bc *SnailBlockChain) HasConfirmedBlock(hash common.Hash, number uint64) bool + func (bc *SnailBlockChain) HasHeader(hash common.Hash, number uint64) bool + func (bc *SnailBlockChain) InsertChain(chain types.SnailBlocks) (int, error) + func (bc *SnailBlockChain) InsertHeaderChain(chain []*types.SnailHeader, checkFreq int) (int, error) + func (bc *SnailBlockChain) IsCanonicalBlock(hash common.Hash, number uint64) bool + func (bc *SnailBlockChain) PostChainEvents(events []interface{}) + func (bc *SnailBlockChain) Reset() error + func (bc *SnailBlockChain) ResetWithGenesisBlock(genesis *types.SnailBlock) error + func (bc *SnailBlockChain) Rollback(chain []common.Hash) + func (bc *SnailBlockChain) SetHead(head uint64) error + func (bc *SnailBlockChain) SetValidator(validator core.SnailValidator) + func (bc *SnailBlockChain) Stop() + func (bc *SnailBlockChain) SubscribeChainEvent(ch chan<- types.SnailChainEvent) event.Subscription + func (bc *SnailBlockChain) SubscribeChainHeadEvent(ch chan<- types.SnailChainHeadEvent) event.Subscription + func (bc *SnailBlockChain) SubscribeChainSideEvent(ch chan<- types.SnailChainSideEvent) event.Subscription + func (bc *SnailBlockChain) SubscribeFastBlockEvent(ch chan<- types.NewFastBlocksEvent) event.Subscription + func (bc *SnailBlockChain) SubscribeNewFruitEvent(ch chan<- types.NewMinedFruitEvent) event.Subscription + func (bc *SnailBlockChain) Validator() core.SnailValidator + func (bc *SnailBlockChain) WriteBlock(block *types.SnailBlock, td *big.Int) (err error) + func (bc *SnailBlockChain) WriteMinedCanonicalBlock(block *types.SnailBlock) (status WriteStatus, err error) + type SnailPool struct + func NewSnailPool(config SnailPoolConfig, fastBlockChain *core.BlockChain, chain core.SnailChain, ...) *SnailPool + func (pool *SnailPool) AddLocals(fruits []*types.SnailBlock) []error + func (pool *SnailPool) AddRemoteFruits(fruits []*types.SnailBlock, local bool) []error + func (pool *SnailPool) Content() []*types.SnailBlock + func (pool *SnailPool) Inspect() []*types.SnailBlock + func (pool *SnailPool) PendingFruits() map[common.Hash]*types.SnailBlock + func (pool *SnailPool) RemovePendingFruitByFastHash(fasthash common.Hash) + func (pool *SnailPool) Start() + func (pool *SnailPool) Stats() (int, int) + func (pool *SnailPool) Stop() + func (pool *SnailPool) SubscribeNewFruitEvent(ch chan<- types.NewFruitsEvent) event.Subscription + type SnailPoolConfig struct + FruitCount uint64 + Journal string + Rejournal time.Duration + type WhCallback func(*types.SnailHeader) error + type WriteStatus byte + const CanonStatTy + const NonStatTy + const SideStatTy