Documentation
¶
Overview ¶
Sync Blockchain
Index ¶
- Constants
- func CheckNonce(nonceMp map[address.Address]uint64, bc blockchain.Blockchains, ...) bool
- type BlockChain
- func (b *BlockChain) AddOrphanBlock(block *block.Block)
- func (b *BlockChain) BlockExists(hash []byte) bool
- func (bc *BlockChain) FindBranchPoint(prevhash, tiphash []byte) ([][]byte, uint64, error)
- func (b *BlockChain) OrphanBlockIsExist(hash []byte) (*block.Block, bool)
- func (b *BlockChain) ProcessBlock(newblock *block.Block, globalDifficulty *big.Int, basePledge uint64) bool
- func (b *BlockChain) ProcessOrphan(block *block.Block) bool
- type Hash
- type OrphanBlock
Constants ¶
const ( MaxEqealBlockWeight = 10 MaxExpiration = time.Hour MaxOrphanBlocks = 200 )
const HashSize int = 32
Variables ¶
This section is empty.
Functions ¶
func CheckNonce ¶
func CheckNonce(nonceMp map[address.Address]uint64, bc blockchain.Blockchains, from address.Address, txNonce uint64) bool
Types ¶
type BlockChain ¶
type BlockChain struct { BlockHeader *block.Block Bc blockchain.Blockchains Oranphs map[Hash]*OrphanBlock PrevOrphans map[Hash][]*OrphanBlock // contains filtered or unexported fields }
func New ¶
func New(bc *blockchain.Blockchain) *BlockChain
func (*BlockChain) AddOrphanBlock ¶
func (b *BlockChain) AddOrphanBlock(block *block.Block)
add block to orphan pool,According to the expiration time to determine whether to retain
func (*BlockChain) BlockExists ¶
func (b *BlockChain) BlockExists(hash []byte) bool
judge block by hash exist
func (*BlockChain) FindBranchPoint ¶
func (bc *BlockChain) FindBranchPoint(prevhash, tiphash []byte) ([][]byte, uint64, error)
func (*BlockChain) OrphanBlockIsExist ¶
func (b *BlockChain) OrphanBlockIsExist(hash []byte) (*block.Block, bool)
func (*BlockChain) ProcessBlock ¶
func (b *BlockChain) ProcessBlock(newblock *block.Block, globalDifficulty *big.Int, basePledge uint64) bool
ProcessBlock is the main workhorse for handling insertion of new blocks into the block chain. It includes functionality such as rejecting duplicate blocks, ensuring blocks follow all rules, orphan handling, and insertion into the block chain along with best chain selection and reorganization.
When no errors occurred during processing, the first return value indicates whether or not the block is on the main chain and the second indicates whether or not the block is an orphan.
func (*BlockChain) ProcessOrphan ¶
func (b *BlockChain) ProcessOrphan(block *block.Block) bool
ProcessOrphan if block prevhash is exist in orphan pool , move all matched orphan blcoks to mainchain,