block

package
v0.5.0-rc5-hotfix2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2019 License: Apache-2.0 Imports: 17 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header
	Footer

	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

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

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

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

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) HashBlock

func (b *Block) HashBlock() hash.Hash256

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

func (*Block) ProducerAddress

func (b *Block) ProducerAddress() string

ProducerAddress returns the address of producer

func (*Block) RunnableActions

func (b *Block) RunnableActions() RunnableActions

RunnableActions abstructs RunnableActions from a Block.

func (*Block) Serialize

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

Serialize returns the serialized byte stream of the block

func (*Block) VerifyDeltaStateDigest

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

VerifyDeltaStateDigest verifies the delta state digest in header

func (*Block) VerifyReceiptRoot

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

VerifyReceiptRoot verifies the receipt root in header

func (*Block) VerifySignature

func (b *Block) VerifySignature() bool

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 NewBuilder

func NewBuilder(ra RunnableActions) *Builder

NewBuilder creates a Builder.

func (*Builder) SetDeltaStateDigest

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) SetPrevBlockHash

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

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

func (*Builder) SetReceiptRoot

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

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

func (*Builder) SetReceipts

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

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

func (*Builder) SetVersion

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

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 struct {
	// contains filtered or unexported fields
}

Footer defines a set of proof of this block

func (*Footer) CommitTime

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

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 added in v0.5.0

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

Endorsements returns the number of commit endorsements froms delegates

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) ByteStream

func (h Header) ByteStream() []byte

ByteStream returns byte stream for header.

func (Header) CoreByteStream added in v0.5.0

func (h Header) CoreByteStream() []byte

CoreByteStream returns byte stream for header core.

func (Header) DeltaStateDigest

func (h Header) DeltaStateDigest() hash.Hash256

DeltaStateDigest returns the delta sate digest after applying this block.

func (Header) HashHeader added in v0.5.0

func (h Header) HashHeader() hash.Hash256

HashHeader hashes the header

func (Header) HashHeaderCore added in v0.5.0

func (h Header) HashHeaderCore() hash.Hash256

HashHeaderCore hahes the header core.

func (Header) HeaderLogger

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

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

func (Header) Height

func (h Header) Height() uint64

Height returns the height of this block.

func (Header) PrevHash

func (h Header) PrevHash() hash.Hash256

PrevHash returns the hash of prev block.

func (Header) PublicKey

func (h Header) PublicKey() keypair.PublicKey

PublicKey returns the public key of this header.

func (Header) ReceiptRoot

func (h Header) ReceiptRoot() hash.Hash256

ReceiptRoot returns the receipt root after apply this block

func (Header) Timestamp

func (h Header) Timestamp() time.Time

Timestamp returns the Timestamp of this block.

func (Header) TxRoot

func (h Header) TxRoot() hash.Hash256

TxRoot returns the hash of all actions in this block.

func (Header) Version

func (h Header) Version() uint32

Version returns the version of 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

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

SetHeight sets the block height for block which is building.

func (*RunnableActionsBuilder) SetTimeStamp

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL