Documentation ¶
Index ¶
- Constants
- func CalculateBlockHash(block interfaces.Block) fields.Hash
- func CalculateBlockHashBaseStuff(block interfaces.Block) []byte
- func CalculateMrklRoot(transactions []interfaces.Transaction) fields.Hash
- func CalculateMrklRootByCoinbaseTxModify(coinbasetxhx fields.Hash, mdftree []fields.Hash) fields.Hash
- func CalculateMrklRootByHashWithFee(hashsWithFee []fields.Hash) fields.Hash
- func NewBlockByVersion(ty uint8) (interfaces.Block, error)
- func ParseBlock(buf []byte, seek uint32) (interfaces.Block, uint32, error)
- func ParseBlockHead(buf []byte, seek uint32) (interfaces.Block, uint32, error)
- func ParseExcludeTransactions(buf []byte, seek uint32) (interfaces.Block, uint32, error)
- func PickMrklListForCoinbaseTxModify(transactions []interfaces.Transaction) []fields.Hash
- type Block_v1
- func (block *Block_v1) AddTransaction(trs interfacev2.Transaction)
- func (block *Block_v1) AddTrs(trs interfaces.Transaction)
- func (block *Block_v1) ArrivedTime() int64
- func (block *Block_v1) CopyForMining() interfaces.Block
- func (block *Block_v1) CopyHeadMetaForMining() interfaces.Block
- func (block *Block_v1) Fresh()
- func (block *Block_v1) GetCustomerTransactionCount() uint32
- func (block *Block_v1) GetDifficulty() uint32
- func (block *Block_v1) GetHeight() uint64
- func (block *Block_v1) GetMrklRoot() fields.Hash
- func (block *Block_v1) GetNonce() uint32
- func (block *Block_v1) GetNonceByte() []byte
- func (block *Block_v1) GetPrevHash() fields.Hash
- func (block *Block_v1) GetTimestamp() uint64
- func (block *Block_v1) GetTransactionCount() uint32
- func (block *Block_v1) GetTransactions() []interfacev2.Transaction
- func (block *Block_v1) GetTrsList() []interfaces.Transaction
- func (block *Block_v1) GetWitnessStage() uint16
- func (block *Block_v1) Hash() fields.Hash
- func (block *Block_v1) HashFresh() fields.Hash
- func (block *Block_v1) OriginMark() string
- func (block *Block_v1) Parse(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) ParseBody(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) ParseExcludeTransactions(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) ParseHead(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) ParseMeta(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) ParseTransactions(buf []byte, seek uint32) (uint32, error)
- func (block *Block_v1) RecoverChainState(blockstate interfacev2.ChainStateOperation) error
- func (block *Block_v1) Serialize() ([]byte, error)
- func (block *Block_v1) SerializeBody() ([]byte, error)
- func (block *Block_v1) SerializeExcludeTransactions() ([]byte, error)
- func (block *Block_v1) SerializeHead() ([]byte, error)
- func (block *Block_v1) SerializeMeta() ([]byte, error)
- func (block *Block_v1) SerializeTransactions(itr interfacev2.SerializeTransactionsIterator) ([]byte, error)
- func (block *Block_v1) SetArrivedTime(ts int64)
- func (block *Block_v1) SetMrklRoot(root fields.Hash)
- func (block *Block_v1) SetNonce(n uint32)
- func (block *Block_v1) SetNonceByte(nonce []byte)
- func (block *Block_v1) SetOriginMark(mark string)
- func (block *Block_v1) SetTransactions(trslist []interfacev2.Transaction)
- func (block *Block_v1) SetTrsList(trslist []interfaces.Transaction)
- func (block *Block_v1) Size() uint32
- func (block *Block_v1) VerifyNeedSigns() (bool, error)
- func (block *Block_v1) Version() uint8
- func (block *Block_v1) WriteInChainState(blockstate interfaces.ChainStateOperation) error
- func (block *Block_v1) WriteinChainState(blockstate interfacev2.ChainStateOperation) error
Constants ¶
View Source
const ( BlockHeadSize = 1 + 5 + 5 + fields.HashSize + fields.HashSize + 4 // = 79 BlockMetaSizeV1 = 4 + 4 + 2 // = 10 )
View Source
const ( BlockVersion = fields.VarUint1(1) // uint8 TransactionType = fields.VarUint1(2) // uint8 ActionKind = fields.VarUint2(12) // uint16 RepairVersion = fields.VarUint2(1) // uint16 )
protocol
Variables ¶
This section is empty.
Functions ¶
func CalculateBlockHash ¶
func CalculateBlockHash(block interfaces.Block) fields.Hash
func CalculateBlockHashBaseStuff ¶
func CalculateBlockHashBaseStuff(block interfaces.Block) []byte
func CalculateMrklRoot ¶
func CalculateMrklRoot(transactions []interfaces.Transaction) fields.Hash
func CalculateMrklRootByCoinbaseTxModify ¶
func CalculateMrklRootByCoinbaseTxModify(coinbasetxhx fields.Hash, mdftree []fields.Hash) fields.Hash
Recalculate Merkel root by modifying the coinbase TX hash
func NewBlockByVersion ¶
func NewBlockByVersion(ty uint8) (interfaces.Block, error)
func ParseBlock ¶
func ParseBlockHead ¶
func PickMrklListForCoinbaseTxModify ¶
func PickMrklListForCoinbaseTxModify(transactions []interfaces.Transaction) []fields.Hash
Calculate and obtain the Merkel related Hash list related to the coinbase TX modification
Types ¶
type Block_v1 ¶
type Block_v1 struct { // head /* Version fields.VarUint1 */ Height fields.BlockHeight Timestamp fields.BlockTxTimestamp PrevHash fields.Hash MrklRoot fields.Hash TransactionCount fields.VarUint4 // meta Nonce fields.VarUint4 // Mining random value Difficulty fields.VarUint4 // Target difficulty value WitnessStage fields.VarUint2 // Witness quantity level // body Transactions []interfaces.Transaction // contains filtered or unexported fields }
func NewEmptyBlockV1 ¶
func NewEmptyBlockV1() *Block_v1
func NewEmptyBlockVersion1 ¶
func NewEmptyBlockVersion1(prevBlockHead interfaces.BlockHeadMetaRead) *Block_v1
func (*Block_v1) AddTransaction ¶
func (block *Block_v1) AddTransaction(trs interfacev2.Transaction)
func (*Block_v1) AddTrs ¶
func (block *Block_v1) AddTrs(trs interfaces.Transaction)
func (*Block_v1) ArrivedTime ¶
func (*Block_v1) CopyHeadMetaForMining ¶
func (block *Block_v1) CopyHeadMetaForMining() interfaces.Block
copy
func (*Block_v1) GetCustomerTransactionCount ¶
func (*Block_v1) GetDifficulty ¶
func (*Block_v1) GetMrklRoot ¶
func (*Block_v1) GetNonceByte ¶
func (*Block_v1) GetPrevHash ¶
func (*Block_v1) GetTimestamp ¶
func (*Block_v1) GetTransactionCount ¶
func (*Block_v1) GetTransactions ¶
func (block *Block_v1) GetTransactions() []interfacev2.Transaction
func (*Block_v1) GetTrsList ¶
func (block *Block_v1) GetTrsList() []interfaces.Transaction
func (*Block_v1) GetWitnessStage ¶
func (*Block_v1) OriginMark ¶
origin: "sync", "discover", "mining"
func (*Block_v1) ParseExcludeTransactions ¶
func (*Block_v1) ParseTransactions ¶
func (*Block_v1) RecoverChainState ¶
func (block *Block_v1) RecoverChainState(blockstate interfacev2.ChainStateOperation) error
func (*Block_v1) SerializeBody ¶
func (*Block_v1) SerializeExcludeTransactions ¶
func (*Block_v1) SerializeHead ¶
func (*Block_v1) SerializeMeta ¶
func (*Block_v1) SerializeTransactions ¶
func (block *Block_v1) SerializeTransactions(itr interfacev2.SerializeTransactionsIterator) ([]byte, error)
func (*Block_v1) SetArrivedTime ¶
func (*Block_v1) SetMrklRoot ¶
func (*Block_v1) SetNonceByte ¶
func (*Block_v1) SetOriginMark ¶
func (*Block_v1) SetTransactions ¶
func (block *Block_v1) SetTransactions(trslist []interfacev2.Transaction)
func (*Block_v1) SetTrsList ¶
func (block *Block_v1) SetTrsList(trslist []interfaces.Transaction)
func (*Block_v1) VerifyNeedSigns ¶
Verify required signatures
func (*Block_v1) WriteInChainState ¶
func (block *Block_v1) WriteInChainState(blockstate interfaces.ChainStateOperation) error
func (*Block_v1) WriteinChainState ¶
func (block *Block_v1) WriteinChainState(blockstate interfacev2.ChainStateOperation) error
修改 / 恢复 状态数据库
Click to show internal directories.
Click to hide internal directories.