Documentation ¶
Index ¶
- Constants
- Variables
- func AsSet(cids []cid.Cid) map[cid.Cid]struct{}
- type Block
- type CISlice
- type ChainInfo
- type FullBlock
- type PoStProof
- type Ticket
- type TipSet
- func (ts TipSet) At(i int) *Block
- func (ts TipSet) Defined() bool
- func (ts TipSet) Equals(ts2 TipSet) bool
- func (ts TipSet) Height() (abi.ChainEpoch, error)
- func (ts TipSet) Key() TipSetKey
- func (ts TipSet) Len() int
- func (ts TipSet) MinTicket() (Ticket, error)
- func (ts TipSet) ParentWeight() (fbig.Int, error)
- func (ts TipSet) Parents() (TipSetKey, error)
- func (ts TipSet) String() string
- func (ts TipSet) ToSlice() []*Block
- type TipSetKey
- func (s *TipSetKey) ContainsAll(other TipSetKey) bool
- func (s TipSetKey) Empty() bool
- func (s TipSetKey) Equals(other TipSetKey) bool
- func (s TipSetKey) Has(id cid.Cid) bool
- func (s TipSetKey) Iter() TipSetKeyIterator
- func (s TipSetKey) Len() int
- func (s TipSetKey) MarshalCBOR() ([]byte, error)
- func (s TipSetKey) MarshalJSON() ([]byte, error)
- func (s TipSetKey) String() string
- func (s TipSetKey) ToSlice() []cid.Cid
- func (s *TipSetKey) UnmarshalCBOR(data []byte) error
- func (s *TipSetKey) UnmarshalJSON(b []byte) error
- type TipSetKeyIterator
Constants ¶
const BlockMessageLimit = 512
BlockMessageLimit is the maximum number of messages in a block
const IndexMessagesField = 10
IndexMessagesField is the message field position in the encoded block
const IndexParentsField = 5
IndexParentsField is the parents field position in the encoded block
Variables ¶
var UndefTipSet = TipSet{}
UndefTipSet is a singleton representing a nil or undefined tipset.
Functions ¶
Types ¶
type Block ¶
type Block struct { // Miner is the address of the miner actor that mined this block. Miner address.Address `json:"miner"` // Ticket is the ticket submitted with this block. Ticket Ticket `json:"ticket"` // ElectionProof is the vrf proof giving this block's miner authoring rights ElectionProof *crypto.ElectionProof // BeaconEntries contain the verifiable oracle randomness used to elect // this block's author leader BeaconEntries []*drand.Entry // PoStProofs are the winning post proofs PoStProofs []PoStProof `json:"PoStProofs"` // Parents is the set of parents this block was based on. Typically one, // but can be several in the case where there were multiple winning ticket- // holders for an epoch. Parents TipSetKey `json:"parents"` // ParentWeight is the aggregate chain weight of the parent set. ParentWeight fbig.Int `json:"parentWeight"` // Height is the chain height of this block. Height abi.ChainEpoch `json:"height"` // StateRoot is the CID of the root of the state tree after application of the messages in the parent tipset // to the parent tipset's state root. StateRoot e.Cid `json:"stateRoot,omitempty"` // MessageReceipts is a list of receipts corresponding to the application of the messages in the parent tipset // to the parent tipset's state root (corresponding to this block's StateRoot). MessageReceipts e.Cid `json:"messageReceipts,omitempty"` // Messages is the set of messages included in this block Messages e.Cid `json:"messages,omitempty"` // The aggregate signature of all BLS signed messages in the block BLSAggregateSig *crypto.Signature `json:"blsAggregateSig"` // The timestamp, in seconds since the Unix epoch, at which this block was created. Timestamp uint64 `json:"timestamp"` // The signature of the miner's worker key over the block BlockSig *crypto.Signature `json:"blocksig"` // ForkSignaling is extra data used by miners to communicate ForkSignaling uint64 // contains filtered or unexported fields }
Block is a block in the blockchain.
func DecodeBlock ¶
DecodeBlock decodes raw cbor bytes into a Block.
func (*Block) SignatureData ¶
SignatureData returns the block's bytes with a null signature field for signature creation and verification
type CISlice ¶
type CISlice []*ChainInfo
CISlice is for sorting chain infos
type ChainInfo ¶
type ChainInfo struct { // The originator of the TipSetKey propagation wave. Source peer.ID // The peer that sent us the TipSetKey message. Sender peer.ID Head TipSetKey Height abi.ChainEpoch }
ChainInfo is used to track metadata about a peer and its chain.
func NewChainInfo ¶
NewChainInfo creates a chain info from a peer id a head tipset key and a chain height.
type FullBlock ¶
type FullBlock struct { Header *Block SECPMessages []*types.SignedMessage BLSMessages []*types.UnsignedMessage }
FullBlock carries a block header and the message and receipt collections referenced from the header.
func NewFullBlock ¶
func NewFullBlock(header *Block, secp []*types.SignedMessage, bls []*types.UnsignedMessage) *FullBlock
NewFullBlock constructs a new full block.
type PoStProof ¶
type PoStProof struct { RegisteredProof abi.RegisteredProof ProofBytes []byte // contains filtered or unexported fields }
PoStProof is a winning post proof included in a block header
func FromABIPoStProofs ¶
FromABIPoStProofs converts the abi post proof type to a local type for serialization purposes
func NewPoStProof ¶
func NewPoStProof(rpp abi.RegisteredProof, bs []byte) PoStProof
NewPoStProof constructs an epost proof from registered proof and bytes
type Ticket ¶
type Ticket struct { // A proof output by running a VRF on the VRFProof of the parent ticket VRFProof crypto.VRFPi // contains filtered or unexported fields }
A Ticket is a marker of a tick of the blockchain's clock. It is the source of randomness for proofs of storage and leader election. It is generated by the miner of a block using a VRF.
type TipSet ¶
type TipSet struct {
// contains filtered or unexported fields
}
TipSet is a non-empty, immutable set of blocks at the same height with the same parent set. Blocks in a tipset are canonically ordered by ticket. Blocks may be iterated either via ToSlice() (which involves a shallow copy) or efficiently by index with At(). TipSet is a lightweight value type; passing by pointer is usually unnecessary.
Canonical tipset block ordering does not match the order of CIDs in a TipSetKey used as a tipset "key".
func NewTipSet ¶
NewTipSet builds a new TipSet from a collection of blocks. The blocks must be distinct (different CIDs), have the same height, and same parent set.
func RequireNewTipSet ¶
RequireNewTipSet instantiates and returns a new tipset of the given blocks and requires that the setup validation succeed.
func (TipSet) At ¶
At returns the i'th block in the tipset. An index outside the half-open range [0, Len()) will panic.
func (TipSet) Defined ¶
Defined checks whether the tipset is defined. Invoking any other methods on an undefined tipset will result in undefined behaviour (c.f. cid.Undef)
func (TipSet) Equals ¶
Equals tests whether the tipset contains the same blocks as another. Equality is not tested deeply: two tipsets are considered equal if their keys (ordered block CIDs) are equal.
func (TipSet) Height ¶
func (ts TipSet) Height() (abi.ChainEpoch, error)
Height returns the height of a tipset.
func (TipSet) ParentWeight ¶
ParentWeight returns the tipset's ParentWeight in fixed point form.
type TipSetKey ¶
type TipSetKey struct {
// contains filtered or unexported fields
}
TipSetKey is an immutable set of CIDs forming a unique key for a TipSet. Equal keys will have equivalent iteration order. CIDs are maintained in the same order as the canonical iteration order of blocks in a tipset (which is by ticket). This convention is maintained by the caller. The order of input cids to the constructor must be the same as this canonical order. It is the caller's responsibility to not construct a key with duplicate ids TipSetKey is a lightweight value type; passing by pointer is usually unnecessary.
func NewTipSetKey ¶
func NewTipSetKey(ids ...cid.Cid) TipSetKey
NewTipSetKey initialises a new TipSetKey. Duplicate CIDs are silently ignored.
func NewTipSetKeyFromUnique ¶
NewTipSetKeyFromUnique initialises a set with CIDs that are expected to be unique.
func (*TipSetKey) ContainsAll ¶
ContainsAll checks if another set is a subset of this one. We can assume that the relative order of members of one key is maintained in the other since we assume that all ids are sorted by corresponding block ticket value.
func (TipSetKey) Iter ¶
func (s TipSetKey) Iter() TipSetKeyIterator
Iter returns an iterator that allows the caller to iterate the set in its sort order.
func (TipSetKey) MarshalCBOR ¶
MarshalCBOR marshals the tipset key as an array of cids
func (TipSetKey) MarshalJSON ¶
MarshalJSON serializes the key to JSON.
func (TipSetKey) ToSlice ¶
func (s TipSetKey) ToSlice() []cid.Cid
ToSlice returns a slice listing the cids in the set.
func (*TipSetKey) UnmarshalCBOR ¶
UnmarshalCBOR unmarshals a cbor array of cids to a tipset key
func (*TipSetKey) UnmarshalJSON ¶
UnmarshalJSON parses JSON into the key. Note that this pattern technically violates the immutability.
type TipSetKeyIterator ¶
type TipSetKeyIterator struct {
// contains filtered or unexported fields
}
TipSetKeyIterator is a iterator over a sorted collection of CIDs.
func (*TipSetKeyIterator) Complete ¶
func (si *TipSetKeyIterator) Complete() bool
Complete returns true if the iterator has reached the end of the set.
func (*TipSetKeyIterator) Next ¶
func (si *TipSetKeyIterator) Next() bool
Next advances the iterator to the next item and returns true if there is such an item.
func (TipSetKeyIterator) Value ¶
func (si TipSetKeyIterator) Value() cid.Cid
Value returns the current item for the iterator