block

package
v1.0.90 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body []*MiniBlock

Body should be used when referring to the full list of mini blocks that forms a block body

func (Body) IntegrityAndValidity

func (b Body) IntegrityAndValidity() error

IntegrityAndValidity checks if data is valid

func (Body) IsInterfaceNil

func (b Body) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type Economics

type Economics struct {
	TotalSupply            *big.Int
	TotalToDistribute      *big.Int
	TotalNewlyMinted       *big.Int
	RewardsPerBlockPerNode *big.Int
	NodePrice              *big.Int
}

Economics holds the block information for total supply and rewards

type EpochStart

type EpochStart struct {
	LastFinalizedHeaders []EpochStartShardData
	Economics            Economics
}

EpochStart holds the block information for end-of-epoch

type EpochStartShardData

type EpochStartShardData struct {
	ShardId                 uint32
	Round                   uint64
	Nonce                   uint64
	HeaderHash              []byte
	RootHash                []byte
	FirstPendingMetaBlock   []byte
	LastFinishedMetaBlock   []byte
	PendingMiniBlockHeaders []ShardMiniBlockHeader
}

EpochStartShardData hold the last finalized headers hash and state root hash

type Header struct {
	Nonce                  uint64
	PrevHash               []byte
	PrevRandSeed           []byte
	RandSeed               []byte
	PubKeysBitmap          []byte
	TimeStamp              uint64
	Round                  uint64
	Signature              []byte
	LeaderSignature        []byte
	RootHash               []byte
	ValidatorStatsRootHash []byte
	MetaBlockHashes        [][]byte
	EpochStartMetaHash     []byte
	ReceiptsHash           []byte
	ChainID                []byte
	MiniBlockHeaders       []MiniBlockHeader
	PeerChanges            []PeerChange
	Epoch                  uint32
	TxCount                uint32
	AccumulatedFees        *big.Int
	ShardId                uint32
	BlockBodyType          Type
}

Header holds the metadata of a block. This is the part that is being hashed and run through consensus. The header holds the hash of the body and also the link to the previous block header hash

func (*Header) CheckChainID

func (h *Header) CheckChainID(reference []byte) error

CheckChainID returns nil if the header's chain ID matches the one provided otherwise, it will error

func (*Header) Clone

func (h *Header) Clone() data.HeaderHandler

Clone returns a clone of the object

func (*Header) GetAccumulatedFees

func (h *Header) GetAccumulatedFees() *big.Int

GetAccumulatedFees returns the accumulated fees in the header

func (*Header) GetChainID

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

GetChainID gets the chain ID on which this block is valid on

func (*Header) GetEpoch

func (h *Header) GetEpoch() uint32

GetEpoch returns header epoch

func (*Header) GetLeaderSignature

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

GetLeaderSignature returns the leader's signature

func (*Header) GetMiniBlockHeadersWithDst

func (h *Header) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32

GetMiniBlockHeadersWithDst as a map of hashes and sender IDs

func (*Header) GetNonce

func (h *Header) GetNonce() uint64

GetNonce returns header nonce

func (*Header) GetPrevHash

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

GetPrevHash returns previous block header hash

func (*Header) GetPrevRandSeed

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

GetPrevRandSeed returns previous random seed

func (*Header) GetPubKeysBitmap

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

GetPubKeysBitmap return signers bitmap

func (*Header) GetRandSeed

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

GetRandSeed returns the random seed

func (*Header) GetReceiptsHash

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

GetReceiptsHash returns the hash of the receipts and intra-shard smart contract results

func (*Header) GetRootHash

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

GetRootHash returns the roothash from header

func (*Header) GetRound

func (h *Header) GetRound() uint64

GetRound returns round from header

func (*Header) GetShardID

func (h *Header) GetShardID() uint32

GetShardID returns header shard id

func (*Header) GetSignature

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

GetSignature returns signed data

func (*Header) GetTimeStamp

func (h *Header) GetTimeStamp() uint64

GetTimeStamp returns the time stamp

func (*Header) GetTxCount

func (h *Header) GetTxCount() uint32

GetTxCount returns transaction count in the block associated with this header

func (*Header) GetValidatorStatsRootHash

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

GetValidatorStatsRootHash returns the root hash for the validator statistics trie at this current block

func (*Header) IsInterfaceNil

func (h *Header) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Header) IsStartOfEpochBlock

func (h *Header) IsStartOfEpochBlock() bool

IsStartOfEpochBlock verifies if the block is of type start of epoch

func (*Header) ItemsInBody added in v1.0.11

func (h *Header) ItemsInBody() uint32

ItemsInBody gets the number of items(hashes) added in block body

func (*Header) ItemsInHeader added in v1.0.11

func (h *Header) ItemsInHeader() uint32

ItemsInHeader gets the number of items(hashes) added in block header

func (*Header) MapMiniBlockHashesToShards

func (h *Header) MapMiniBlockHashesToShards() map[string]uint32

MapMiniBlockHashesToShards is a map of mini block hashes and sender IDs

func (*Header) SetAccumulatedFees

func (h *Header) SetAccumulatedFees(value *big.Int)

SetAccumulatedFees sets the accumulated fees in the header

func (*Header) SetChainID

func (h *Header) SetChainID(chainID []byte)

SetChainID sets the chain ID on which this block is valid on

func (*Header) SetEpoch

func (h *Header) SetEpoch(e uint32)

SetEpoch sets header epoch

func (*Header) SetLeaderSignature

func (h *Header) SetLeaderSignature(sg []byte)

SetLeaderSignature will set the leader's signature

func (*Header) SetNonce

func (h *Header) SetNonce(n uint64)

SetNonce sets header nonce

func (*Header) SetPrevHash

func (h *Header) SetPrevHash(pvHash []byte)

SetPrevHash sets prev hash

func (*Header) SetPrevRandSeed

func (h *Header) SetPrevRandSeed(pvRandSeed []byte)

SetPrevRandSeed sets previous random seed

func (*Header) SetPubKeysBitmap

func (h *Header) SetPubKeysBitmap(pkbm []byte)

SetPubKeysBitmap sets publick key bitmap

func (*Header) SetRandSeed

func (h *Header) SetRandSeed(randSeed []byte)

SetRandSeed sets previous random seed

func (*Header) SetRootHash

func (h *Header) SetRootHash(rHash []byte)

SetRootHash sets root hash

func (*Header) SetRound

func (h *Header) SetRound(r uint64)

SetRound sets header round

func (*Header) SetShardID

func (h *Header) SetShardID(shId uint32)

SetShardID sets header shard ID

func (*Header) SetSignature

func (h *Header) SetSignature(sg []byte)

SetSignature sets header signature

func (*Header) SetTimeStamp

func (h *Header) SetTimeStamp(ts uint64)

SetTimeStamp sets header timestamp

func (*Header) SetTxCount

func (h *Header) SetTxCount(txCount uint32)

SetTxCount sets the transaction count of the block associated with this header

func (*Header) SetValidatorStatsRootHash

func (h *Header) SetValidatorStatsRootHash(rHash []byte)

SetValidatorStatsRootHash set's the root hash for the validator statistics trie

type MetaBlock

type MetaBlock struct {
	Nonce                  uint64
	Round                  uint64
	TimeStamp              uint64
	ShardInfo              []ShardData
	Signature              []byte
	LeaderSignature        []byte
	PubKeysBitmap          []byte
	PrevHash               []byte
	PrevRandSeed           []byte
	RandSeed               []byte
	RootHash               []byte
	ValidatorStatsRootHash []byte
	MiniBlockHeaders       []MiniBlockHeader
	ReceiptsHash           []byte
	EpochStart             EpochStart
	ChainID                []byte
	Epoch                  uint32
	TxCount                uint32
	AccumulatedFees        *big.Int
	AccumulatedFeesInEpoch *big.Int
}

MetaBlock holds the data that will be saved to the metachain each round

func (*MetaBlock) CheckChainID

func (m *MetaBlock) CheckChainID(reference []byte) error

CheckChainID returns nil if the header's chain ID matches the one provided otherwise, it will error

func (*MetaBlock) Clone

func (m *MetaBlock) Clone() data.HeaderHandler

Clone will return a clone of the object

func (*MetaBlock) GetAccumulatedFees

func (m *MetaBlock) GetAccumulatedFees() *big.Int

GetAccumulatedFees returns the accumulated fees in the header

func (*MetaBlock) GetChainID

func (m *MetaBlock) GetChainID() []byte

GetChainID gets the chain ID on which this block is valid on

func (*MetaBlock) GetEpoch

func (m *MetaBlock) GetEpoch() uint32

GetEpoch return header epoch

func (*MetaBlock) GetLeaderSignature

func (m *MetaBlock) GetLeaderSignature() []byte

GetLeaderSignature returns the signature of the leader

func (*MetaBlock) GetMiniBlockHeadersWithDst

func (m *MetaBlock) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32

GetMiniBlockHeadersWithDst as a map of hashes and sender IDs

func (*MetaBlock) GetNonce

func (m *MetaBlock) GetNonce() uint64

GetNonce return header nonce

func (*MetaBlock) GetPrevHash

func (m *MetaBlock) GetPrevHash() []byte

GetPrevHash returns previous block header hash

func (*MetaBlock) GetPrevRandSeed

func (m *MetaBlock) GetPrevRandSeed() []byte

GetPrevRandSeed gets the previous random seed

func (*MetaBlock) GetPubKeysBitmap

func (m *MetaBlock) GetPubKeysBitmap() []byte

GetPubKeysBitmap return signers bitmap

func (*MetaBlock) GetRandSeed

func (m *MetaBlock) GetRandSeed() []byte

GetRandSeed gets the current random seed

func (*MetaBlock) GetReceiptsHash

func (m *MetaBlock) GetReceiptsHash() []byte

GetReceiptsHash returns the hash of the receipts and intra-shard smart contract results

func (*MetaBlock) GetRootHash

func (m *MetaBlock) GetRootHash() []byte

GetRootHash returns the roothash from header

func (*MetaBlock) GetRound

func (m *MetaBlock) GetRound() uint64

GetRound return round from header

func (*MetaBlock) GetShardID

func (m *MetaBlock) GetShardID() uint32

GetShardID returns the metachain shard id

func (*MetaBlock) GetSignature

func (m *MetaBlock) GetSignature() []byte

GetSignature return signed data

func (*MetaBlock) GetTimeStamp

func (m *MetaBlock) GetTimeStamp() uint64

GetTimeStamp returns the time stamp

func (*MetaBlock) GetTxCount

func (m *MetaBlock) GetTxCount() uint32

GetTxCount returns transaction count in the current meta block

func (*MetaBlock) GetValidatorStatsRootHash

func (m *MetaBlock) GetValidatorStatsRootHash() []byte

GetValidatorStatsRootHash returns the root hash for the validator statistics trie at this current block

func (*MetaBlock) IsInterfaceNil

func (m *MetaBlock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*MetaBlock) IsStartOfEpochBlock

func (m *MetaBlock) IsStartOfEpochBlock() bool

IsStartOfEpochBlock verifies if the block is of type start of epoch

func (*MetaBlock) ItemsInBody added in v1.0.11

func (m *MetaBlock) ItemsInBody() uint32

ItemsInBody gets the number of items(hashes) added in block body

func (*MetaBlock) ItemsInHeader added in v1.0.11

func (m *MetaBlock) ItemsInHeader() uint32

ItemsInHeader gets the number of items(hashes) added in block header

func (*MetaBlock) SetAccumulatedFees

func (m *MetaBlock) SetAccumulatedFees(value *big.Int)

SetAccumulatedFees sets the accumulated fees in the header

func (*MetaBlock) SetChainID

func (m *MetaBlock) SetChainID(chainID []byte)

SetChainID sets the chain ID on which this block is valid on

func (*MetaBlock) SetEpoch

func (m *MetaBlock) SetEpoch(e uint32)

SetEpoch sets header epoch

func (*MetaBlock) SetLeaderSignature

func (m *MetaBlock) SetLeaderSignature(sg []byte)

SetLeaderSignature will set the leader's signature

func (*MetaBlock) SetNonce

func (m *MetaBlock) SetNonce(n uint64)

SetNonce sets header nonce

func (*MetaBlock) SetPrevHash

func (m *MetaBlock) SetPrevHash(pvHash []byte)

SetPrevHash sets prev hash

func (*MetaBlock) SetPrevRandSeed

func (m *MetaBlock) SetPrevRandSeed(pvRandSeed []byte)

SetPrevRandSeed sets the previous randomness seed

func (*MetaBlock) SetPubKeysBitmap

func (m *MetaBlock) SetPubKeysBitmap(pkbm []byte)

SetPubKeysBitmap sets publick key bitmap

func (*MetaBlock) SetRandSeed

func (m *MetaBlock) SetRandSeed(randSeed []byte)

SetRandSeed sets the current random seed

func (*MetaBlock) SetRootHash

func (m *MetaBlock) SetRootHash(rHash []byte)

SetRootHash sets root hash

func (*MetaBlock) SetRound

func (m *MetaBlock) SetRound(r uint64)

SetRound sets header round

func (*MetaBlock) SetShardID

func (m *MetaBlock) SetShardID(_ uint32)

SetShardID sets header shard ID

func (*MetaBlock) SetSignature

func (m *MetaBlock) SetSignature(sg []byte)

SetSignature set header signature

func (*MetaBlock) SetTimeStamp

func (m *MetaBlock) SetTimeStamp(ts uint64)

SetTimeStamp sets header timestamp

func (*MetaBlock) SetTxCount

func (m *MetaBlock) SetTxCount(txCount uint32)

SetTxCount sets the transaction count of the current meta block

func (*MetaBlock) SetValidatorStatsRootHash

func (m *MetaBlock) SetValidatorStatsRootHash(rHash []byte)

SetValidatorStatsRootHash set's the root hash for the validator statistics trie

type MiniBlock

type MiniBlock struct {
	TxHashes        [][]byte
	ReceiverShardID uint32
	SenderShardID   uint32
	Type            Type
}

MiniBlock holds the transactions and the sender/destination shard ids

func (*MiniBlock) Clone

func (mb *MiniBlock) Clone() *MiniBlock

Clone the underlying data

type MiniBlockHeader

type MiniBlockHeader struct {
	Hash            []byte
	SenderShardID   uint32
	ReceiverShardID uint32
	TxCount         uint32
	Type            Type
}

MiniBlockHeader holds the hash of a miniblock together with sender/deastination shard id pair. The shard ids are both kept in order to differentiate between cross and single shard transactions

type MiniBlockSlice

type MiniBlockSlice []*MiniBlock

MiniBlockSlice should be used when referring to subset of mini blocks that is not

necessarily representing a full block body

type PeerAction

type PeerAction uint8

PeerAction type represents the possible events that a node can trigger for the metachain to notarize

const (
	PeerRegistration PeerAction = iota + 1
	PeerUnstaking
	PeerDeregistration
	PeerJailed
	PeerUnJailed
	PeerSlashed
	PeerReStake
)

Constants mapping the actions that a node can take

func (PeerAction) String

func (pa PeerAction) String() string

type PeerChange

type PeerChange struct {
	PubKey      []byte
	ShardIdDest uint32
}

PeerChange holds a change in one peer to shard assignation

type PeerData

type PeerData struct {
	Address     []byte
	PublicKey   []byte
	Action      PeerAction
	TimeStamp   uint64
	ValueChange *big.Int
}

PeerData holds information about actions taken by a peer:

  • a peer can register with an amount to become a validator
  • a peer can choose to deregister and get back the deposited value

type ShardData

type ShardData struct {
	HeaderHash            []byte
	ShardMiniBlockHeaders []ShardMiniBlockHeader
	PrevRandSeed          []byte
	PubKeysBitmap         []byte
	Signature             []byte
	Round                 uint64
	PrevHash              []byte
	Nonce                 uint64
	NumPendingMiniBlocks  uint32
	ShardID               uint32
	TxCount               uint32
	AccumulatedFees       *big.Int
}

ShardData holds the block information sent by the shards to the metachain

type ShardMiniBlockHeader

type ShardMiniBlockHeader struct {
	Hash            []byte
	ReceiverShardID uint32
	SenderShardID   uint32
	TxCount         uint32
}

ShardMiniBlockHeader holds data for one shard miniblock header

type Type

type Type uint8

Type identifies the type of the block

const (
	// TxBlock identifies a miniblock holding transactions
	TxBlock Type = 0
	// StateBlock identifies a miniblock holding account state
	StateBlock Type = 30
	// PeerBlock identifies a miniblock holding peer assignation
	PeerBlock Type = 60
	// SmartContractResultBlock identifies a miniblock holding smartcontractresults
	SmartContractResultBlock Type = 90
	// InvalidBlock identifies a miniblock holding invalid transactions
	InvalidBlock Type = 120
	// ReceiptBlock identifies a miniblock holding receipts
	ReceiptBlock Type = 150

	// RewardsBlock identifies a miniblock holding accumulated rewards, both system generated and from tx fees
	RewardsBlock Type = 255
)

func (Type) String

func (bType Type) String() string

String returns the string representation of the Type

Jump to

Keyboard shortcuts

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