iotex-core: github.com/iotexproject/iotex-core/blockchain/block Index | Files

package block

import "github.com/iotexproject/iotex-core/blockchain/block"

Index

Package Files

block.go body.go builder.go footer.go header.go runnable.go testing.go utils.go

type Block Uses

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 Uses

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 Uses

func (b *Block) ConvertFromBlockPb(pbBlock *iotextypes.Block) error

ConvertFromBlockPb converts Block to Block

func (*Block) ConvertToBlockHeaderPb Uses

func (b *Block) ConvertToBlockHeaderPb() *iotextypes.BlockHeader

ConvertToBlockHeaderPb converts BlockHeader to BlockHeader

func (*Block) ConvertToBlockPb Uses

func (b *Block) ConvertToBlockPb() *iotextypes.Block

ConvertToBlockPb converts Block to Block

func (*Block) Deserialize Uses

func (b *Block) Deserialize(buf []byte) error

Deserialize parses the byte stream into a Block

func (*Block) Finalize Uses

func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error

Finalize creates a footer for the block

func (*Block) RunnableActions Uses

func (b *Block) RunnableActions() RunnableActions

RunnableActions abstructs RunnableActions from a Block.

func (*Block) Serialize Uses

func (b *Block) Serialize() ([]byte, error)

Serialize returns the serialized byte stream of the block

func (*Block) VerifyDeltaStateDigest Uses

func (b *Block) VerifyDeltaStateDigest(digest hash.Hash256) error

VerifyDeltaStateDigest verifies the delta state digest in header

func (*Block) VerifyReceiptRoot Uses

func (b *Block) VerifyReceiptRoot(root hash.Hash256) error

VerifyReceiptRoot verifies the receipt root in header

type Body Uses

type Body struct {
    Actions []action.SealedEnvelope
}

Body defines the struct of body

func (*Body) CalculateTransferAmount Uses

func (b *Body) CalculateTransferAmount() *big.Int

CalculateTransferAmount returns the calculated transfer amount in this block.

func (*Body) CalculateTxRoot Uses

func (b *Body) CalculateTxRoot() hash.Hash256

CalculateTxRoot returns the Merkle root of all txs and actions in this block.

func (*Body) Deserialize Uses

func (b *Body) Deserialize(buf []byte) error

Deserialize parses the byte stream into a Block

func (*Body) LoadProto Uses

func (b *Body) LoadProto(pbBlock *iotextypes.BlockBody) error

LoadProto loads body from proto

func (*Body) Proto Uses

func (b *Body) Proto() *iotextypes.BlockBody

Proto converts Body to Protobuf

func (*Body) Serialize Uses

func (b *Body) Serialize() ([]byte, error)

Serialize returns the serialized byte stream of the block

type Builder Uses

type Builder struct {
    // contains filtered or unexported fields
}

Builder is used to construct Block.

func NewBuilder Uses

func NewBuilder(ra RunnableActions) *Builder

NewBuilder creates a Builder.

func (*Builder) SetDeltaStateDigest Uses

func (b *Builder) SetDeltaStateDigest(h hash.Hash256) *Builder

SetDeltaStateDigest sets the new delta state digest after running actions included in this building block

func (*Builder) SetHeight Uses

func (b *Builder) SetHeight(h uint64) *Builder

SetHeight sets the block height

func (*Builder) SetLogsBloom Uses

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 Uses

func (b *Builder) SetPrevBlockHash(h hash.Hash256) *Builder

SetPrevBlockHash sets the previous block hash for block which is building.

func (*Builder) SetReceiptRoot Uses

func (b *Builder) SetReceiptRoot(h hash.Hash256) *Builder

SetReceiptRoot sets the receipt root after running actions included in this building block.

func (*Builder) SetReceipts Uses

func (b *Builder) SetReceipts(receipts []*action.Receipt) *Builder

SetReceipts sets the receipts after running actions included in this building block.

func (*Builder) SetTimestamp Uses

func (b *Builder) SetTimestamp(ts time.Time) *Builder

SetTimestamp sets the block timestamp

func (*Builder) SetVersion Uses

func (b *Builder) SetVersion(v uint32) *Builder

SetVersion sets the protocol version for block which is building.

func (*Builder) SignAndBuild Uses

func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)

SignAndBuild signs and then builds a block.

type Footer struct {
    // contains filtered or unexported fields
}

Footer defines a set of proof of this block

func (*Footer) CommitTime Uses

func (f *Footer) CommitTime() time.Time

CommitTime returns the timestamp the block was committed

func (*Footer) ConvertFromBlockFooterPb Uses

func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error

ConvertFromBlockFooterPb converts BlockFooter to BlockFooter

func (*Footer) ConvertToBlockFooterPb Uses

func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)

ConvertToBlockFooterPb converts BlockFooter

func (*Footer) Deserialize Uses

func (f *Footer) Deserialize(buf []byte) error

Deserialize loads from the serialized byte stream

func (*Footer) Endorsements Uses

func (f *Footer) Endorsements() []*endorsement.Endorsement

Endorsements returns the number of commit endorsements froms delegates

func (*Footer) Serialize Uses

func (f *Footer) Serialize() ([]byte, error)

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 (*Header) BlockHeaderCoreProto Uses

func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore

BlockHeaderCoreProto returns BlockHeaderCore proto.

func (*Header) BlockHeaderProto Uses

func (h *Header) BlockHeaderProto() *iotextypes.BlockHeader

BlockHeaderProto returns BlockHeader proto.

func (*Header) DeltaStateDigest Uses

func (h *Header) DeltaStateDigest() hash.Hash256

DeltaStateDigest returns the delta sate digest after applying this block.

func (*Header) Deserialize Uses

func (h *Header) Deserialize(buf []byte) error

Deserialize loads from the serialized byte stream

func (*Header) HashBlock Uses

func (h *Header) HashBlock() hash.Hash256

HashBlock return the hash of this block (actually hash of block header)

func (*Header) HashHeader Uses

func (h *Header) HashHeader() hash.Hash256

HashHeader hashes the header

func (*Header) HashHeaderCore Uses

func (h *Header) HashHeaderCore() hash.Hash256

HashHeaderCore hahes the header core.

func (*Header) HeaderLogger Uses

func (h *Header) HeaderLogger(l *zap.Logger) *zap.Logger

HeaderLogger returns a new logger with block header fields' value.

func (*Header) Height Uses

func (h *Header) Height() uint64

Height returns the height of this block.

func (*Header) LoadFromBlockHeaderProto Uses

func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error

LoadFromBlockHeaderProto loads from protobuf

func (*Header) LogsBloomfilter Uses

func (h *Header) LogsBloomfilter() bloom.BloomFilter

LogsBloomfilter return the bloom filter for all contract log events

func (*Header) PrevHash Uses

func (h *Header) PrevHash() hash.Hash256

PrevHash returns the hash of prev block.

func (*Header) ProducerAddress Uses

func (h *Header) ProducerAddress() string

ProducerAddress returns the address of producer

func (*Header) PublicKey Uses

func (h *Header) PublicKey() crypto.PublicKey

PublicKey returns the public key of this header.

func (*Header) ReceiptRoot Uses

func (h *Header) ReceiptRoot() hash.Hash256

ReceiptRoot returns the receipt root after apply this block

func (*Header) Serialize Uses

func (h *Header) Serialize() ([]byte, error)

Serialize returns the serialized byte stream of the block header

func (*Header) SerializeCore Uses

func (h *Header) SerializeCore() []byte

SerializeCore returns byte stream for header core.

func (*Header) Timestamp Uses

func (h *Header) Timestamp() time.Time

Timestamp returns the Timestamp of this block.

func (*Header) TxRoot Uses

func (h *Header) TxRoot() hash.Hash256

TxRoot returns the hash of all actions in this block.

func (*Header) VerifySignature Uses

func (h *Header) VerifySignature() bool

VerifySignature verifies the signature saved in block header

func (*Header) Version Uses

func (h *Header) Version() uint32

Version returns the version of this block.

type RunnableActions Uses

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 Uses

func (ra RunnableActions) Actions() []action.SealedEnvelope

Actions returns Actions.

func (RunnableActions) TxHash Uses

func (ra RunnableActions) TxHash() hash.Hash256

TxHash returns TxHash.

type RunnableActionsBuilder Uses

type RunnableActionsBuilder struct {
    // contains filtered or unexported fields
}

RunnableActionsBuilder is used to construct RunnableActions.

func NewRunnableActionsBuilder Uses

func NewRunnableActionsBuilder() *RunnableActionsBuilder

NewRunnableActionsBuilder creates a RunnableActionsBuilder.

func (*RunnableActionsBuilder) AddActions Uses

func (b *RunnableActionsBuilder) AddActions(acts ...action.SealedEnvelope) *RunnableActionsBuilder

AddActions adds actions for block which is building.

func (*RunnableActionsBuilder) Build Uses

func (b *RunnableActionsBuilder) Build() RunnableActions

Build signs and then builds a block.

type TestingBuilder Uses

type TestingBuilder struct {
    // contains filtered or unexported fields
}

TestingBuilder is used to construct Block.

func NewTestingBuilder Uses

func NewTestingBuilder() *TestingBuilder

NewTestingBuilder creates a Builder.

func (*TestingBuilder) AddActions Uses

func (b *TestingBuilder) AddActions(acts ...action.SealedEnvelope) *TestingBuilder

AddActions adds actions for block which is building.

func (*TestingBuilder) SetHeight Uses

func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder

SetHeight sets the block height for block which is building.

func (*TestingBuilder) SetPrevBlockHash Uses

func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder

SetPrevBlockHash sets the previous block hash for block which is building.

func (*TestingBuilder) SetReceipts Uses

func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder

SetReceipts sets the receipts after running actions included in this building block.

func (*TestingBuilder) SetTimeStamp Uses

func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder

SetTimeStamp sets the time stamp for block which is building.

func (*TestingBuilder) SetVersion Uses

func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder

SetVersion sets the protocol version for block which is building.

func (*TestingBuilder) SignAndBuild Uses

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.