Documentation ¶
Index ¶
- Variables
- func DeserializeBlockStoresPb(buf []byte) (*iotextypes.BlockStores, error)
- func DeserializeSystemLogPb(buf []byte) (*iotextypes.TransactionLogs, error)
- func GenesisHash() hash.Hash256
- func LoadGenesisHash(g *genesis.Genesis)
- type BlkTransactionLog
- 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) TransactionLog() *BlkTransactionLog
- func (b *Block) VerifyTxRoot() error
- type Body
- type Builder
- func (b *Builder) GetCurrentBlockHeader() Header
- func (b *Builder) SetDeltaStateDigest(h hash.Hash256) *Builder
- func (b *Builder) SetHeight(h uint64) *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) SetTimestamp(ts time.Time) *Builder
- func (b *Builder) SetVersion(v uint32) *Builder
- func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
- type Deserializer
- func (bd *Deserializer) DeserializeBlock(buf []byte) (*Block, error)
- func (bd *Deserializer) DeserializeBody(buf []byte) (*Body, error)
- func (bd *Deserializer) FromBlockProto(pbBlock *iotextypes.Block) (*Block, error)
- func (bd *Deserializer) FromBodyProto(pbBody *iotextypes.BlockBody) (*Body, 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) VerifyDeltaStateDigest(digest hash.Hash256) bool
- func (h *Header) VerifyReceiptRoot(root hash.Hash256) bool
- func (h *Header) VerifySignature() bool
- func (h *Header) VerifyTransactionRoot(root hash.Hash256) bool
- func (h *Header) Version() uint32
- type RunnableActions
- type RunnableActionsBuilder
- type Store
- 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)
- type TokenTxRecord
- type TransactionLog
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrTxRootMismatch = errors.New("transaction merkle root does not match") ErrDeltaStateMismatch = errors.New("delta state digest doesn't match") ErrReceiptRootMismatch = errors.New("receipt root hash does not match") )
Errors
Functions ¶
func DeserializeBlockStoresPb ¶ added in v1.1.2
func DeserializeBlockStoresPb(buf []byte) (*iotextypes.BlockStores, error)
DeserializeBlockStoresPb decode byte stream into BlockStores pb message
func DeserializeSystemLogPb ¶ added in v1.1.0
func DeserializeSystemLogPb(buf []byte) (*iotextypes.TransactionLogs, error)
DeserializeSystemLogPb parse the byte stream into TransactionLogs Pb message
func GenesisHash ¶ added in v1.2.0
GenesisHash returns the genesis block's hash
func LoadGenesisHash ¶ added in v1.2.0
LoadGenesisHash is done once to compute and save the genesis'es hash
Types ¶
type BlkTransactionLog ¶ added in v1.1.0
type BlkTransactionLog struct {
// contains filtered or unexported fields
}
BlkTransactionLog is transaction log in one block
func (*BlkTransactionLog) Serialize ¶ added in v1.1.0
func (log *BlkTransactionLog) Serialize() []byte
Serialize returns a serialized byte stream for BlkTransactionLog
type Block ¶
type Block struct { Header Body // TODO: move receipts out of block struct Receipts []*action.Receipt }
Block defines the struct of block
func GenesisBlock ¶ added in v1.2.0
func GenesisBlock() *Block
GenesisBlock returns the genesis 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) TransactionLog ¶ added in v1.1.0
func (b *Block) TransactionLog() *BlkTransactionLog
TransactionLog returns transaction logs in the block
func (*Block) VerifyTxRoot ¶ added in v1.1.2
VerifyTxRoot verifies the transaction root hash
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) GetCurrentBlockHeader ¶ added in v0.11.0
GetCurrentBlockHeader returns the current hash of Block Header Core
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) SetTimestamp ¶ added in v0.11.0
SetTimestamp sets the block timestamp
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 Deserializer ¶ added in v1.8.0
type Deserializer struct { }
Deserializer de-serializes a block
func (*Deserializer) DeserializeBlock ¶ added in v1.8.0
func (bd *Deserializer) DeserializeBlock(buf []byte) (*Block, error)
DeserializeBlock de-serializes a block
func (*Deserializer) DeserializeBody ¶ added in v1.8.0
func (bd *Deserializer) DeserializeBody(buf []byte) (*Body, error)
DeserializeBody de-serializes a block body
func (*Deserializer) FromBlockProto ¶ added in v1.8.0
func (bd *Deserializer) FromBlockProto(pbBlock *iotextypes.Block) (*Block, error)
FromBlockProto converts protobuf to block
func (*Deserializer) FromBodyProto ¶ added in v1.8.0
func (bd *Deserializer) FromBodyProto(pbBody *iotextypes.BlockBody) (*Body, error)
FromBodyProto converts protobuf to body
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) VerifyDeltaStateDigest ¶ added in v1.7.1
VerifyDeltaStateDigest verifies the delta state digest in header
func (*Header) VerifyReceiptRoot ¶ added in v1.7.1
VerifyReceiptRoot verifies the receipt root in header
func (*Header) VerifySignature ¶ added in v0.5.0
VerifySignature verifies the signature saved in block header
func (*Header) VerifyTransactionRoot ¶ added in v1.7.1
VerifyTransactionRoot verifies the delta state digest in 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) 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() RunnableActions
Build signs and then builds a block.
type Store ¶ added in v1.1.2
Store defines block storage schema
func (*Store) Deserialize ¶ added in v1.1.2
Deserialize parses the byte stream into Store
func (*Store) FromProto ¶ added in v1.1.2
func (in *Store) FromProto(pb *iotextypes.BlockStore) error
FromProto converts from proto message
func (*Store) ToProto ¶ added in v1.1.2
func (in *Store) ToProto() *iotextypes.BlockStore
ToProto converts to proto message
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.
type TokenTxRecord ¶ added in v1.1.0
type TokenTxRecord struct {
// contains filtered or unexported fields
}
TokenTxRecord is a token transaction record
func LogTokenTxRecord ¶ added in v1.1.0
func LogTokenTxRecord(l *action.TransactionLog) *TokenTxRecord
LogTokenTxRecord generates token transaction record from log
func NewTokenTxRecord ¶ added in v1.1.0
func NewTokenTxRecord(typ iotextypes.TransactionLogType, amount, sender, recipient string) *TokenTxRecord
NewTokenTxRecord creates a new TokenTxRecord
type TransactionLog ¶ added in v1.1.0
type TransactionLog struct {
// contains filtered or unexported fields
}
TransactionLog is transaction log in one action
func NewTransactionLog ¶ added in v1.1.0
func NewTransactionLog(actHash hash.Hash256, records []*TokenTxRecord) *TransactionLog
NewTransactionLog creates a new TransactionLog
func ReceiptTransactionLog ¶ added in v1.1.0
func ReceiptTransactionLog(r *action.Receipt) *TransactionLog
ReceiptTransactionLog generates transaction log from receipt
func (*TransactionLog) Proto ¶ added in v1.1.0
func (log *TransactionLog) Proto() *iotextypes.TransactionLog
Proto returns the pb message
type Validator ¶ added in v0.11.0
type Validator interface { // Validate validates the given block's content Validate(ctx context.Context, block *Block) error }
Validator is the interface of validator
func NewValidator ¶ added in v0.11.0
func NewValidator(subsequenceValidator Validator, validators ...action.SealedEnvelopeValidator) Validator
NewValidator creates a validator with a set of sealed envelope validators