Documentation ¶
Index ¶
- type Block
- func (b *Block) ConvertFromBlockPb(pbBlock *iotextypes.Block) error
- func (b *Block) ConvertToBlockHeaderPb() *iotextypes.BlockHeader
- func (b *Block) ConvertToBlockPb() *iotextypes.Block
- func (b *Block) Deserialize(buf []byte) error
- func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error
- func (b *Block) RunnableActions() RunnableActions
- func (b *Block) Serialize() ([]byte, error)
- func (b *Block) VerifyDeltaStateDigest(digest hash.Hash256) error
- func (b *Block) VerifyReceiptRoot(root hash.Hash256) error
- type Body
- type Builder
- func (b *Builder) SetDeltaStateDigest(h hash.Hash256) *Builder
- func (b *Builder) SetLogsBloom(f bloom.BloomFilter) *Builder
- func (b *Builder) SetPrevBlockHash(h hash.Hash256) *Builder
- func (b *Builder) SetReceiptRoot(h hash.Hash256) *Builder
- func (b *Builder) SetReceipts(receipts []*action.Receipt) *Builder
- func (b *Builder) SetVersion(v uint32) *Builder
- func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
- type Footer
- func (f *Footer) CommitTime() time.Time
- func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error
- func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)
- func (f *Footer) Deserialize(buf []byte) error
- func (f *Footer) Endorsements() []*endorsement.Endorsement
- func (f *Footer) Serialize() ([]byte, error)
- type Header
- func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
- func (h *Header) BlockHeaderProto() *iotextypes.BlockHeader
- func (h *Header) DeltaStateDigest() hash.Hash256
- func (h *Header) Deserialize(buf []byte) error
- func (h *Header) HashBlock() hash.Hash256
- func (h *Header) HashHeader() hash.Hash256
- func (h *Header) HashHeaderCore() hash.Hash256
- func (h *Header) HeaderLogger(l *zap.Logger) *zap.Logger
- func (h *Header) Height() uint64
- func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error
- func (h *Header) LogsBloomfilter() bloom.BloomFilter
- func (h *Header) PrevHash() hash.Hash256
- func (h *Header) ProducerAddress() string
- func (h *Header) PublicKey() crypto.PublicKey
- func (h *Header) ReceiptRoot() hash.Hash256
- func (h *Header) Serialize() ([]byte, error)
- func (h *Header) SerializeCore() []byte
- func (h *Header) Timestamp() time.Time
- func (h *Header) TxRoot() hash.Hash256
- func (h *Header) VerifySignature() bool
- func (h *Header) Version() uint32
- type RunnableActions
- type RunnableActionsBuilder
- func (b *RunnableActionsBuilder) AddActions(acts ...action.SealedEnvelope) *RunnableActionsBuilder
- func (b *RunnableActionsBuilder) Build(producerPubKey crypto.PublicKey) RunnableActions
- func (b *RunnableActionsBuilder) SetHeight(h uint64) *RunnableActionsBuilder
- func (b *RunnableActionsBuilder) SetTimeStamp(ts time.Time) *RunnableActionsBuilder
- type TestingBuilder
- func (b *TestingBuilder) AddActions(acts ...action.SealedEnvelope) *TestingBuilder
- func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder
- func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder
- func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder
- func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder
- func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder
- func (b *TestingBuilder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Header Body // TODO: move receipts out of block struct Receipts []*action.Receipt WorkingSet factory.WorkingSet }
Block defines the struct of block
func NewBlockDeprecated ¶
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 (*Block) ConvertFromBlockPb ¶
func (b *Block) ConvertFromBlockPb(pbBlock *iotextypes.Block) error
ConvertFromBlockPb converts Block to Block
func (*Block) ConvertToBlockHeaderPb ¶
func (b *Block) ConvertToBlockHeaderPb() *iotextypes.BlockHeader
ConvertToBlockHeaderPb converts BlockHeader to BlockHeader
func (*Block) ConvertToBlockPb ¶
func (b *Block) ConvertToBlockPb() *iotextypes.Block
ConvertToBlockPb converts Block to Block
func (*Block) Deserialize ¶
Deserialize parses the byte stream into a Block
func (*Block) Finalize ¶
func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error
Finalize creates a footer for the block
func (*Block) RunnableActions ¶
func (b *Block) RunnableActions() RunnableActions
RunnableActions abstructs RunnableActions from a Block.
func (*Block) VerifyDeltaStateDigest ¶
VerifyDeltaStateDigest verifies the delta state digest in header
type Body ¶ added in v0.5.0
type Body struct {
Actions []action.SealedEnvelope
}
Body defines the struct of body
func (*Body) CalculateTransferAmount ¶ added in v0.9.0
CalculateTransferAmount returns the calculated transfer amount in this block.
func (*Body) CalculateTxRoot ¶ added in v0.5.0
CalculateTxRoot returns the Merkle root of all txs and actions in this block.
func (*Body) Deserialize ¶ added in v0.5.0
Deserialize parses the byte stream into a Block
func (*Body) LoadProto ¶ added in v0.5.0
func (b *Body) LoadProto(pbBlock *iotextypes.BlockBody) error
LoadProto loads body from proto
func (*Body) Proto ¶ added in v0.5.0
func (b *Body) Proto() *iotextypes.BlockBody
Proto converts Body to Protobuf
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to construct Block.
func (*Builder) SetDeltaStateDigest ¶
SetDeltaStateDigest sets the new delta state digest after running actions included in this building block
func (*Builder) SetLogsBloom ¶ added in v0.7.1
func (b *Builder) SetLogsBloom(f bloom.BloomFilter) *Builder
SetLogsBloom sets the logs bloom filter value after running actions included in this building block.
func (*Builder) SetPrevBlockHash ¶
SetPrevBlockHash sets the previous block hash for block which is building.
func (*Builder) SetReceiptRoot ¶
SetReceiptRoot sets the receipt root after running actions included in this building block.
func (*Builder) SetReceipts ¶
SetReceipts sets the receipts after running actions included in this building block.
func (*Builder) SetVersion ¶
SetVersion sets the protocol version for block which is building.
func (*Builder) SignAndBuild ¶
func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.
type Footer ¶
type Footer struct {
// contains filtered or unexported fields
}
Footer defines a set of proof of this block
func (*Footer) CommitTime ¶
CommitTime returns the timestamp the block was committed
func (*Footer) ConvertFromBlockFooterPb ¶
func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error
ConvertFromBlockFooterPb converts BlockFooter to BlockFooter
func (*Footer) ConvertToBlockFooterPb ¶
func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)
ConvertToBlockFooterPb converts BlockFooter
func (*Footer) Deserialize ¶ added in v0.5.0
Deserialize loads from the serialized byte stream
func (*Footer) Endorsements ¶ added in v0.5.0
func (f *Footer) Endorsements() []*endorsement.Endorsement
Endorsements returns the number of commit endorsements froms delegates
type Header ¶
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 (*Header) BlockHeaderCoreProto ¶ added in v0.5.0
func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
BlockHeaderCoreProto returns BlockHeaderCore proto.
func (*Header) BlockHeaderProto ¶ added in v0.5.0
func (h *Header) BlockHeaderProto() *iotextypes.BlockHeader
BlockHeaderProto returns BlockHeader proto.
func (*Header) DeltaStateDigest ¶
DeltaStateDigest returns the delta sate digest after applying this block.
func (*Header) Deserialize ¶ added in v0.5.0
Deserialize loads from the serialized byte stream
func (*Header) HashBlock ¶ added in v0.5.0
HashBlock return the hash of this block (actually hash of block header)
func (*Header) HashHeader ¶ added in v0.5.0
HashHeader hashes the header
func (*Header) HashHeaderCore ¶ added in v0.5.0
HashHeaderCore hahes the header core.
func (*Header) HeaderLogger ¶
HeaderLogger returns a new logger with block header fields' value.
func (*Header) LoadFromBlockHeaderProto ¶ added in v0.5.0
func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error
LoadFromBlockHeaderProto loads from protobuf
func (*Header) LogsBloomfilter ¶ added in v0.7.1
func (h *Header) LogsBloomfilter() bloom.BloomFilter
LogsBloomfilter return the bloom filter for all contract log events
func (*Header) ProducerAddress ¶ added in v0.5.0
ProducerAddress returns the address of producer
func (*Header) ReceiptRoot ¶
ReceiptRoot returns the receipt root after apply this block
func (*Header) Serialize ¶ added in v0.5.0
Serialize returns the serialized byte stream of the block header
func (*Header) SerializeCore ¶ added in v0.7.1
SerializeCore returns byte stream for header core.
func (*Header) VerifySignature ¶ added in v0.5.0
VerifySignature verifies the signature saved in block header
type RunnableActions ¶
type RunnableActions struct {
// contains filtered or unexported fields
}
RunnableActions is abstructed from block which contains information to execute all actions in a block.
func (RunnableActions) Actions ¶
func (ra RunnableActions) Actions() []action.SealedEnvelope
Actions returns Actions.
func (RunnableActions) BlockHeight ¶
func (ra RunnableActions) BlockHeight() uint64
BlockHeight returns block height.
func (RunnableActions) BlockProducerPubKey ¶
func (ra RunnableActions) BlockProducerPubKey() crypto.PublicKey
BlockProducerPubKey return BlockProducerPubKey.
func (RunnableActions) BlockTimeStamp ¶
func (ra RunnableActions) BlockTimeStamp() time.Time
BlockTimeStamp returns blockTimeStamp.
func (RunnableActions) TxHash ¶
func (ra RunnableActions) TxHash() hash.Hash256
TxHash returns TxHash.
type RunnableActionsBuilder ¶
type RunnableActionsBuilder struct {
// contains filtered or unexported fields
}
RunnableActionsBuilder is used to construct RunnableActions.
func NewRunnableActionsBuilder ¶
func NewRunnableActionsBuilder() *RunnableActionsBuilder
NewRunnableActionsBuilder creates a RunnableActionsBuilder.
func (*RunnableActionsBuilder) AddActions ¶
func (b *RunnableActionsBuilder) AddActions(acts ...action.SealedEnvelope) *RunnableActionsBuilder
AddActions adds actions for block which is building.
func (*RunnableActionsBuilder) Build ¶
func (b *RunnableActionsBuilder) Build(producerPubKey crypto.PublicKey) RunnableActions
Build signs and then builds a block.
func (*RunnableActionsBuilder) SetHeight ¶
func (b *RunnableActionsBuilder) SetHeight(h uint64) *RunnableActionsBuilder
SetHeight sets the block height for block which is building.
func (*RunnableActionsBuilder) SetTimeStamp ¶
func (b *RunnableActionsBuilder) SetTimeStamp(ts time.Time) *RunnableActionsBuilder
SetTimeStamp sets the time stamp for block which is building.
type TestingBuilder ¶
type TestingBuilder struct {
// contains filtered or unexported fields
}
TestingBuilder is used to construct Block.
func NewTestingBuilder ¶
func NewTestingBuilder() *TestingBuilder
NewTestingBuilder creates a Builder.
func (*TestingBuilder) AddActions ¶
func (b *TestingBuilder) AddActions(acts ...action.SealedEnvelope) *TestingBuilder
AddActions adds actions for block which is building.
func (*TestingBuilder) SetHeight ¶
func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder
SetHeight sets the block height for block which is building.
func (*TestingBuilder) SetPrevBlockHash ¶
func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder
SetPrevBlockHash sets the previous block hash for block which is building.
func (*TestingBuilder) SetReceipts ¶
func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder
SetReceipts sets the receipts after running actions included in this building block.
func (*TestingBuilder) SetTimeStamp ¶
func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder
SetTimeStamp sets the time stamp for block which is building.
func (*TestingBuilder) SetVersion ¶
func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder
SetVersion sets the protocol version for block which is building.
func (*TestingBuilder) SignAndBuild ¶
func (b *TestingBuilder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.