Documentation ¶
Index ¶
- type Block
- func (b *Block) CalculateTxRoot() hash.Hash256
- func (b *Block) ConvertFromBlockHeaderPb(pbBlock *iotextypes.Block) error
- 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) HashBlock() hash.Hash256
- func (b *Block) ProducerAddress() string
- 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
- func (b *Block) VerifySignature() bool
- type Builder
- func (b *Builder) SetDeltaStateDigest(h hash.Hash256) *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 keypair.PrivateKey) (Block, error)
- type Footer
- type Header
- func (h Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
- func (h Header) BlockHeaderProto() *iotextypes.BlockHeader
- func (h Header) ByteStream() []byte
- func (h Header) CoreByteStream() []byte
- func (h Header) DeltaStateDigest() 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) PrevHash() hash.Hash256
- func (h Header) PublicKey() keypair.PublicKey
- func (h Header) ReceiptRoot() hash.Hash256
- func (h Header) Timestamp() time.Time
- func (h Header) TxRoot() hash.Hash256
- func (h Header) Version() uint32
- type RunnableActions
- type RunnableActionsBuilder
- func (b *RunnableActionsBuilder) AddActions(acts ...action.SealedEnvelope) *RunnableActionsBuilder
- func (b *RunnableActionsBuilder) Build(producerPubKey keypair.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(signerPubKey keypair.PublicKey, signerPrvKey keypair.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 Actions []action.SealedEnvelope // 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 keypair.PublicKey, actions []action.SealedEnvelope, ) *Block
NewBlockDeprecated returns a new block This method is deprecated. Only used in old tests.
func (*Block) CalculateTxRoot ¶
CalculateTxRoot returns the Merkle root of all txs and actions in this block.
func (*Block) ConvertFromBlockHeaderPb ¶
func (b *Block) ConvertFromBlockHeaderPb(pbBlock *iotextypes.Block) error
ConvertFromBlockHeaderPb converts BlockHeader to BlockHeader
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) ProducerAddress ¶
ProducerAddress returns the address of producer
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
func (*Block) VerifyReceiptRoot ¶
VerifyReceiptRoot verifies the receipt root in header
func (*Block) VerifySignature ¶
VerifySignature verifies the signature saved in block header
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) 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 keypair.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) Endorsements ¶
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 ¶
func (h Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
BlockHeaderCoreProto returns BlockHeaderCore proto.
func (Header) BlockHeaderProto ¶
func (h Header) BlockHeaderProto() *iotextypes.BlockHeader
BlockHeaderProto returns BlockHeader proto.
func (Header) ByteStream ¶
ByteStream returns byte stream for header.
func (Header) CoreByteStream ¶
CoreByteStream returns byte stream for header core.
func (Header) DeltaStateDigest ¶
DeltaStateDigest returns the delta sate digest after applying this block.
func (Header) HashHeaderCore ¶
HashHeaderCore hahes the header core.
func (Header) HeaderLogger ¶
HeaderLogger returns a new logger with block header fields' value.
func (Header) ReceiptRoot ¶
ReceiptRoot returns the receipt root after apply this block
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() keypair.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 keypair.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(signerPubKey keypair.PublicKey, signerPrvKey keypair.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.