import "github.com/iotexproject/iotex-core/blockchain/block"
block.go body.go builder.go footer.go header.go runnable.go testing.go utils.go
type Block struct { Header Body Footer // TODO: move receipts out of block struct Receipts []*action.Receipt WorkingSet factory.WorkingSet }
Block defines the struct of block
func NewBlockDeprecated( chainID uint32, height uint64, prevBlockHash hash.Hash256, timestamp time.Time, producer crypto.PublicKey, actions []action.SealedEnvelope, ) *Block
NewBlockDeprecated returns a new block This method is deprecated. Only used in old tests.
func (b *Block) ConvertFromBlockPb(pbBlock *iotextypes.Block) error
ConvertFromBlockPb converts Block to Block
func (b *Block) ConvertToBlockHeaderPb() *iotextypes.BlockHeader
ConvertToBlockHeaderPb converts BlockHeader to BlockHeader
func (b *Block) ConvertToBlockPb() *iotextypes.Block
ConvertToBlockPb converts Block to Block
Deserialize parses the byte stream into a Block
func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error
Finalize creates a footer for the block
func (b *Block) RunnableActions() RunnableActions
RunnableActions abstructs RunnableActions from a Block.
Serialize returns the serialized byte stream of the block
VerifyDeltaStateDigest verifies the delta state digest in header
VerifyReceiptRoot verifies the receipt root in header
type Body struct { Actions []action.SealedEnvelope }
Body defines the struct of body
CalculateTransferAmount returns the calculated transfer amount in this block.
CalculateTxRoot returns the Merkle root of all txs and actions in this block.
Deserialize parses the byte stream into a Block
func (b *Body) LoadProto(pbBlock *iotextypes.BlockBody) error
LoadProto loads body from proto
func (b *Body) Proto() *iotextypes.BlockBody
Proto converts Body to Protobuf
Serialize returns the serialized byte stream of the block
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to construct Block.
func NewBuilder(ra RunnableActions) *Builder
NewBuilder creates a Builder.
SetDeltaStateDigest sets the new delta state digest after running actions included in this building block
SetHeight sets the block height
func (b *Builder) SetLogsBloom(f bloom.BloomFilter) *Builder
SetLogsBloom sets the logs bloom filter value after running actions included in this building block.
SetPrevBlockHash sets the previous block hash for block which is building.
SetReceiptRoot sets the receipt root after running actions included in this building block.
SetReceipts sets the receipts after running actions included in this building block.
SetTimestamp sets the block timestamp
SetVersion sets the protocol version for block which is building.
SignAndBuild signs and then builds a block.
type Footer struct {
// contains filtered or unexported fields
}
Footer defines a set of proof of this block
CommitTime returns the timestamp the block was committed
func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error
ConvertFromBlockFooterPb converts BlockFooter to BlockFooter
func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)
ConvertToBlockFooterPb converts BlockFooter
Deserialize loads from the serialized byte stream
func (f *Footer) Endorsements() []*endorsement.Endorsement
Endorsements returns the number of commit endorsements froms delegates
Serialize returns the serialized byte stream of the block footer
type Header struct {
// contains filtered or unexported fields
}
Header defines the struct of block header make sure the variable type and order of this struct is same as "BlockHeaderPb" in blockchain.pb.go
func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
BlockHeaderCoreProto returns BlockHeaderCore proto.
func (h *Header) BlockHeaderProto() *iotextypes.BlockHeader
BlockHeaderProto returns BlockHeader proto.
DeltaStateDigest returns the delta sate digest after applying this block.
Deserialize loads from the serialized byte stream
HashBlock return the hash of this block (actually hash of block header)
HashHeader hashes the header
HashHeaderCore hahes the header core.
HeaderLogger returns a new logger with block header fields' value.
Height returns the height of this block.
func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error
LoadFromBlockHeaderProto loads from protobuf
func (h *Header) LogsBloomfilter() bloom.BloomFilter
LogsBloomfilter return the bloom filter for all contract log events
PrevHash returns the hash of prev block.
ProducerAddress returns the address of producer
PublicKey returns the public key of this header.
ReceiptRoot returns the receipt root after apply this block
Serialize returns the serialized byte stream of the block header
SerializeCore returns byte stream for header core.
Timestamp returns the Timestamp of this block.
TxRoot returns the hash of all actions in this block.
VerifySignature verifies the signature saved in block header
Version returns the version of this block.
type RunnableActions struct {
// contains filtered or unexported fields
}
RunnableActions is abstructed from block which contains information to execute all actions in a block.
func (ra RunnableActions) Actions() []action.SealedEnvelope
Actions returns Actions.
func (ra RunnableActions) TxHash() hash.Hash256
TxHash returns TxHash.
type RunnableActionsBuilder struct {
// contains filtered or unexported fields
}
RunnableActionsBuilder is used to construct RunnableActions.
func NewRunnableActionsBuilder() *RunnableActionsBuilder
NewRunnableActionsBuilder creates a RunnableActionsBuilder.
func (b *RunnableActionsBuilder) AddActions(acts ...action.SealedEnvelope) *RunnableActionsBuilder
AddActions adds actions for block which is building.
func (b *RunnableActionsBuilder) Build() RunnableActions
Build signs and then builds a block.
type TestingBuilder struct {
// contains filtered or unexported fields
}
TestingBuilder is used to construct Block.
func NewTestingBuilder() *TestingBuilder
NewTestingBuilder creates a Builder.
func (b *TestingBuilder) AddActions(acts ...action.SealedEnvelope) *TestingBuilder
AddActions adds actions for block which is building.
func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder
SetHeight sets the block height for block which is building.
func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder
SetPrevBlockHash sets the previous block hash for block which is building.
func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder
SetReceipts sets the receipts after running actions included in this building block.
func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder
SetTimeStamp sets the time stamp for block which is building.
func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder
SetVersion sets the protocol version for block which is building.
func (b *TestingBuilder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.
Package block imports 19 packages (graph) and is imported by 13 packages. Updated 2019-12-05. Refresh now. Tools for package owners.