block

package
v1.0.37 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeaderGoToCapn added in v1.0.3

func HeaderGoToCapn(seg *capn.Segment, src *Header) capnp.HeaderCapn

HeaderGoToCapn is a helper function to copy fields from a Block Header object to a HeaderCapn object

func MetaBlockGoToCapn added in v1.0.3

func MetaBlockGoToCapn(seg *capn.Segment, src *MetaBlock) capnp.MetaBlockCapn

MetaBlockGoToCapn is a helper function to copy fields from a MetaBlock object to a MetaBlockCapn object

func MiniBlockGoToCapn added in v1.0.3

func MiniBlockGoToCapn(seg *capn.Segment, src *MiniBlock) capnp.MiniBlockCapn

MiniBlockGoToCapn is a helper function to copy fields from a MiniBlock object to a MiniBlockCapn object

func MiniBlockHeaderGoToCapn added in v1.0.3

func MiniBlockHeaderGoToCapn(seg *capn.Segment, src *MiniBlockHeader) capnp.MiniBlockHeaderCapn

MiniBlockHeaderGoToCapn is a helper function to copy fields from a MiniBlockHeader object to a MiniBlockHeaderCapn object

func PeerChangeGoToCapn added in v1.0.3

func PeerChangeGoToCapn(seg *capn.Segment, src *PeerChange) capnp.PeerChangeCapn

PeerChangeGoToCapn is a helper function to copy fields from a PeerChange object to a PeerChangeGoToCapn object

func PeerDataGoToCapn added in v1.0.3

func PeerDataGoToCapn(seg *capn.Segment, src *PeerData) capnp.PeerDataCapn

PeerDataGoToCapn is a helper function to copy fields from a Peer Data object to a PeerDataCapn object

func ShardDataGoToCapn added in v1.0.3

func ShardDataGoToCapn(seg *capn.Segment, src *ShardData) capnp.ShardDataCapn

ShardDataGoToCapn is a helper function to copy fields from a ShardData object to a ShardDataCapn object

func ShardMiniBlockHeaderGoToCapn added in v1.0.3

func ShardMiniBlockHeaderGoToCapn(seg *capn.Segment, src *ShardMiniBlockHeader) capnp.ShardMiniBlockHeaderCapn

ShardMiniBlockHeaderGoToCapn is a helper function to copy fields from a ShardMiniBlockHeader object to a ShardMiniBlockHeaderCapn object

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 Header struct {
	Nonce            uint64            `capid:"0"`
	PrevHash         []byte            `capid:"1"`
	PrevRandSeed     []byte            `capid:"2"`
	RandSeed         []byte            `capid:"3"`
	PubKeysBitmap    []byte            `capid:"4"`
	ShardId          uint32            `capid:"5"`
	TimeStamp        uint64            `capid:"6"`
	Round            uint64            `capid:"7"`
	Epoch            uint32            `capid:"8"`
	BlockBodyType    Type              `capid:"9"`
	Signature        []byte            `capid:"10"`
	MiniBlockHeaders []MiniBlockHeader `capid:"11"`
	PeerChanges      []PeerChange      `capid:"12"`
	RootHash         []byte            `capid:"13"`
	MetaBlockHashes  [][]byte          `capid:"14"`
	TxCount          uint32            `capid:"15"`
}

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 HeaderCapnToGo added in v1.0.3

func HeaderCapnToGo(src capnp.HeaderCapn, dest *Header) *Header

HeaderCapnToGo is a helper function to copy fields from a HeaderCapn object to a Header object

func (*Header) GetEpoch

func (h *Header) GetEpoch() uint32

GetEpoch returns header epoch

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

func (h *Header) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

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) Load added in v1.0.3

func (h *Header) Load(r io.Reader) error

Load loads the data from the stream into a Block Header object through Capnp protocol

func (*Header) MapMiniBlockHashesToShards

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

GetAllMiniBlockHashes as a map of hashes and sender IDs

func (*Header) Save added in v1.0.3

func (h *Header) Save(w io.Writer) error

Save saves the serialized data of a Block Header into a stream through Capnp protocol

func (*Header) SetEpoch

func (h *Header) SetEpoch(e uint32)

SetEpoch sets header epoch

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

type MetaBlock

type MetaBlock struct {
	Nonce         uint64      `capid:"0"`
	Epoch         uint32      `capid:"1"`
	Round         uint64      `capid:"2"`
	TimeStamp     uint64      `capid:"3"`
	ShardInfo     []ShardData `capid:"4"`
	PeerInfo      []PeerData  `capid:"5"`
	Signature     []byte      `capid:"6"`
	PubKeysBitmap []byte      `capid:"7"`
	PrevHash      []byte      `capid:"8"`
	PrevRandSeed  []byte      `capid:"9"`
	RandSeed      []byte      `capid:"10"`
	RootHash      []byte      `capid:"11"`
	TxCount       uint32      `capid:"12"`
}

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

func MetaBlockCapnToGo added in v1.0.3

func MetaBlockCapnToGo(src capnp.MetaBlockCapn, dest *MetaBlock) *MetaBlock

MetaBlockCapnToGo is a helper function to copy fields from a MetaBlockCapn object to a MetaBlock object

func (*MetaBlock) GetEpoch

func (m *MetaBlock) GetEpoch() uint32

GetEpoch return header epoch

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

func (m *MetaBlock) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

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) Load added in v1.0.3

func (m *MetaBlock) Load(r io.Reader) error

Load loads the data from the stream into a MetaBlock object through Capnp protocol

func (*MetaBlock) Save added in v1.0.3

func (m *MetaBlock) Save(w io.Writer) error

Save saves the serialized data of a MetaBlock into a stream through Capnp protocol

func (*MetaBlock) SetEpoch

func (m *MetaBlock) SetEpoch(e uint32)

SetEpoch sets header epoch

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

type MetaBlockBody added in v1.0.3

type MetaBlockBody struct {
}

MetaBlockBody hold the data for metablock body

func (*MetaBlockBody) IntegrityAndValidity added in v1.0.3

func (m *MetaBlockBody) IntegrityAndValidity() error

IntegrityAndValidity return true as block is nil for metablock.

func (*MetaBlockBody) IsInterfaceNil added in v1.0.16

func (m *MetaBlockBody) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type MiniBlock

type MiniBlock struct {
	TxHashes        [][]byte `capid:"0"`
	ReceiverShardID uint32   `capid:"1"`
	SenderShardID   uint32   `capid:"2"`
	Type            Type     `capid:"3"`
}

MiniBlock holds the transactions and the sender/destination shard ids

func MiniBlockCapnToGo added in v1.0.3

func MiniBlockCapnToGo(src capnp.MiniBlockCapn, dest *MiniBlock) *MiniBlock

MiniBlockCapnToGo is a helper function to copy fields from a MiniBlockCapn object to a MiniBlock object

func (*MiniBlock) Load added in v1.0.3

func (s *MiniBlock) Load(r io.Reader) error

Load loads the data from the stream into a MiniBlock object through Capnp protocol

func (*MiniBlock) Save added in v1.0.3

func (s *MiniBlock) Save(w io.Writer) error

Save saves the serialized data of a MiniBlock into a stream through Capnp protocol

type MiniBlockHeader

type MiniBlockHeader struct {
	Hash            []byte `capid:"0"`
	SenderShardID   uint32 `capid:"1"`
	ReceiverShardID uint32 `capid:"2"`
	TxCount         uint32 `capid:"3"`
	Type            Type   `capid:"4"`
}

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

func MiniBlockHeaderCapnToGo added in v1.0.3

func MiniBlockHeaderCapnToGo(src capnp.MiniBlockHeaderCapn, dest *MiniBlockHeader) *MiniBlockHeader

MiniBlockHeaderCapnToGo is a helper function to copy fields from a MiniBlockHeaderCapn object to a MiniBlockHeader object

func (*MiniBlockHeader) Load added in v1.0.3

func (s *MiniBlockHeader) Load(r io.Reader) error

Load loads the data from the stream into a StateBlockBody object through Capnp protocol

func (*MiniBlockHeader) Save added in v1.0.3

func (s *MiniBlockHeader) Save(w io.Writer) error

Save saves the serialized data of a StateBlockBody into a stream through Capnp protocol

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 (
	PeerRegistrantion PeerAction = iota + 1
	PeerDeregistration
)

Constants mapping the actions that a node can take

func (PeerAction) String

func (pa PeerAction) String() string

type PeerChange

type PeerChange struct {
	PubKey      []byte `capid:"0"`
	ShardIdDest uint32 `capid:"1"`
}

PeerChange holds a change in one peer to shard assignation

func PeerChangeCapnToGo added in v1.0.3

func PeerChangeCapnToGo(src capnp.PeerChangeCapn, dest *PeerChange) *PeerChange

PeerChangeCapnToGo is a helper function to copy fields from a PeerChangeCapn object to a PeerChange object

func (*PeerChange) Load added in v1.0.3

func (s *PeerChange) Load(r io.Reader) error

Load loads the data from the stream into a PeerChange object through Capnp protocol

func (*PeerChange) Save added in v1.0.3

func (s *PeerChange) Save(w io.Writer) error

Save saves the serialized data of a PeerChange into a stream through Capnp protocol

type PeerData

type PeerData struct {
	PublicKey []byte     `capid:"0"`
	Action    PeerAction `capid:"1"`
	TimeStamp uint64     `capid:"2"`
	Value     *big.Int   `capid:"3"`
}

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

func PeerDataCapnToGo added in v1.0.3

func PeerDataCapnToGo(src capnp.PeerDataCapn, dest *PeerData) *PeerData

PeerDataCapnToGo is a helper function to copy fields from a PeerDataCapn object to a PeerData object

func (*PeerData) Load added in v1.0.3

func (p *PeerData) Load(r io.Reader) error

Load loads the data from the stream into a PeerData object through Capnp protocol

func (*PeerData) Save added in v1.0.3

func (p *PeerData) Save(w io.Writer) error

Save saves the serialized data of a PeerData into a stream through Capnp protocol

type ShardData

type ShardData struct {
	ShardId               uint32                 `capid:"0"`
	HeaderHash            []byte                 `capid:"1"`
	ShardMiniBlockHeaders []ShardMiniBlockHeader `capid:"2"`
	TxCount               uint32                 `capid:"3"`
}

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

func ShardDataCapnToGo added in v1.0.3

func ShardDataCapnToGo(src capnp.ShardDataCapn, dest *ShardData) *ShardData

ShardDataCapnToGo is a helper function to copy fields from a ShardDataCapn object to a ShardData object

func (*ShardData) Load added in v1.0.3

func (s *ShardData) Load(r io.Reader) error

Load loads the data from the stream into a ShardData object through Capnp protocol

func (*ShardData) Save added in v1.0.3

func (s *ShardData) Save(w io.Writer) error

Save saves the serialized data of a ShardData into a stream through Capnp protocol

type ShardMiniBlockHeader

type ShardMiniBlockHeader struct {
	Hash            []byte `capid:"0"`
	ReceiverShardId uint32 `capid:"1"`
	SenderShardId   uint32 `capid:"2"`
	TxCount         uint32 `capid:"3"`
}

ShardMiniBlockHeader holds data for one shard miniblock header

func ShardMiniBlockHeaderCapnToGo added in v1.0.3

func ShardMiniBlockHeaderCapnToGo(src capnp.ShardMiniBlockHeaderCapn, dest *ShardMiniBlockHeader) *ShardMiniBlockHeader

ShardMiniBlockHeaderCapnToGo is a helper function to copy fields from a ShardMiniBlockHeaderCapn object to a ShardMiniBlockHeader object

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 = 1
	// PeerBlock identifies a miniblock holding peer assignation
	PeerBlock Type = 2
	// SmartContractResultBlock identifies a miniblock holding smartcontractresults
	SmartContractResultBlock Type = 3
	// RewardsBlock identifies a miniblock holding accumulated rewards, both system generated and from tx fees
	RewardsBlock Type = 4
	// InvalidBlock identifies identifies an invalid miniblock
	InvalidBlock Type = 5
)

func (Type) String

func (bType Type) String() string

String returns the string representation of the Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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