Documentation ¶
Overview ¶
nolint
nolint
nolint
nolint
nolint
Package types defines the types used by go-spacemesh consensus algorithms and structs ¶
nolint
nolint
nolint
nolint
nolint
nolint
nolint
Index ¶
- Constants
- Variables
- func BlockIdsField(ids blockIDs) log.Field
- func GetLayersPerEpoch() uint32
- func IsProcessingError(err error) bool
- func RandomBytes(size int) []byte
- func SetLayersPerEpoch(layers uint32)
- func Shorten(s string, maxlen int) string
- func TxIdsField(ids []TransactionID) log.Field
- type ATXID
- func (t ATXID) Bytes() []byte
- func (t *ATXID) DecodeScale(d *scale.Decoder) (int, error)
- func (t *ATXID) EncodeScale(e *scale.Encoder) (int, error)
- func (t ATXID) Field() log.Field
- func (t ATXID) Hash32() Hash32
- func (t ATXID) Less(other ATXID) bool
- func (t ATXID) ShortString() string
- func (t ATXID) String() string
- type ATXIDList
- type ATXMetadata
- type Account
- type ActivationTx
- func (atx *ActivationTx) CalcAndSetID() error
- func (atx *ActivationTx) CalcAndSetNodeID() error
- func (t *ActivationTx) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (atx *ActivationTx) EffectiveNumUnits() uint32
- func (t *ActivationTx) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (atx *ActivationTx) GetPoetProofRef() Hash32
- func (atx *ActivationTx) GetShortPoetProofRef() []byte
- func (atx *ActivationTx) HashInnerBytes() []byte
- func (atx *ActivationTx) ID() ATXID
- func (atx *ActivationTx) MarshalLogObject(encoder log.ObjectEncoder) error
- func (atx *ActivationTx) NodeID() NodeID
- func (atx *ActivationTx) Received() time.Time
- func (atx *ActivationTx) SetEffectiveNumUnits(numUnits uint32)
- func (atx *ActivationTx) SetID(id *ATXID)
- func (atx *ActivationTx) SetMetadata()
- func (atx *ActivationTx) SetNodeID(nodeID *NodeID)
- func (atx *ActivationTx) SetReceived(received time.Time)
- func (atx *ActivationTx) ShortString() string
- func (atx *ActivationTx) SignedBytes() []byte
- func (atx *ActivationTx) Verify(baseTickHeight, tickCount uint64) (*VerifiedActivationTx, error)
- type ActivationTxHeader
- type Address
- func (a Address) Bytes() []byte
- func (a *Address) DecodeScale(d *scale.Decoder) (int, error)
- func (a *Address) EncodeScale(e *scale.Encoder) (int, error)
- func (a Address) Field() log.Field
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) GetHRPNetwork() string
- func (a Address) IsEmpty() bool
- func (a Address) String() string
- type AddressNonce
- type AnyReward
- type AtxProof
- type AtxProofMsg
- type Ballot
- func (t *Ballot) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *Ballot) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (b *Ballot) HashInnerBytes() []byte
- func (b *Ballot) ID() BallotID
- func (b *Ballot) Initialize() error
- func (b *Ballot) IsMalicious() bool
- func (b *Ballot) MarshalLogObject(encoder log.ObjectEncoder) error
- func (b *Ballot) SetID(id BallotID)
- func (b *Ballot) SetMalicious()
- func (b *Ballot) SetMetadata()
- func (b *Ballot) SetSmesherID(id NodeID)
- func (b *Ballot) SignedBytes() []byte
- func (b *Ballot) SmesherID() NodeID
- type BallotID
- func (id BallotID) AsHash32() Hash32
- func (id BallotID) Bytes() []byte
- func (id BallotID) Compare(other BallotID) bool
- func (id *BallotID) DecodeScale(d *scale.Decoder) (int, error)
- func (id *BallotID) EncodeScale(e *scale.Encoder) (int, error)
- func (id BallotID) Field() log.Field
- func (id BallotID) String() string
- type BallotMetadata
- type BallotProof
- type BallotProofMsg
- type Beacon
- type Block
- func (b *Block) Bytes() []byte
- func (t *Block) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *Block) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (b *Block) ID() BlockID
- func (b *Block) Initialize()
- func (b *Block) MarshalLogObject(encoder log.ObjectEncoder) error
- func (b *Block) ToVote() Vote
- type BlockContextualValidity
- type BlockID
- func (id BlockID) AsHash32() Hash32
- func (id BlockID) Bytes() []byte
- func (id BlockID) Compare(other BlockID) bool
- func (id *BlockID) DecodeScale(d *scale.Decoder) (int, error)
- func (id *BlockID) EncodeScale(e *scale.Encoder) (int, error)
- func (id BlockID) Field() log.Field
- func (id BlockID) String() string
- type Bytes64
- type Certificate
- type CertifyContent
- type CertifyMessage
- type Config
- type EligibilityType
- type EpochData
- type EpochID
- type HareEligibility
- type HareEligibilityGossip
- type HareMetadata
- type HareProof
- type HareProofMsg
- type Hash12
- type Hash20
- func (h Hash20) Big() *big.Int
- func (h Hash20) Bytes() []byte
- func (h *Hash20) DecodeScale(d *scale.Decoder) (int, error)
- func (h Hash20) Field() log.Field
- func (h Hash20) Format(s fmt.State, c rune)
- func (h Hash20) Hex() string
- func (h Hash20) MarshalText() ([]byte, error)
- func (h *Hash20) SetBytes(b []byte)
- func (h Hash20) ShortString() string
- func (h Hash20) String() string
- func (h Hash20) ToHash32() (h32 Hash32)
- func (h *Hash20) UnmarshalJSON(input []byte) error
- func (h *Hash20) UnmarshalText(input []byte) error
- type Hash32
- func ATXIDsToHashes(ids []ATXID) []Hash32
- func BallotIDsToHashes(ids []BallotID) []Hash32
- func BlockIDsToHashes(ids []BlockID) []Hash32
- func BytesToHash(b []byte) Hash32
- func CalcBlockHash32Presorted(sortedView []BlockID, additionalBytes []byte) Hash32
- func CalcBlocksHash32(view []BlockID, additionalBytes []byte) Hash32
- func CalcHash32(data []byte) Hash32
- func CalcObjectHash32(obj scale.Encodable) Hash32
- func CalcProposalHash32Presorted(sortedView []ProposalID, additionalBytes []byte) Hash32
- func CalcProposalsHash32(view []ProposalID, additionalBytes []byte) Hash32
- func HexToHash32(s string) Hash32
- func NodeIDsToHashes(ids []NodeID) []Hash32
- func ProposalIDsToHashes(ids []ProposalID) []Hash32
- func RandomHash() Hash32
- func TransactionIDsToHashes(ids []TransactionID) []Hash32
- func (h Hash32) Bytes() []byte
- func (h *Hash32) DecodeScale(d *scale.Decoder) (int, error)
- func (h *Hash32) EncodeScale(e *scale.Encoder) (int, error)
- func (h Hash32) Field() log.Field
- func (h Hash32) Format(s fmt.State, c rune)
- func (h Hash32) Hex() string
- func (h Hash32) MarshalText() ([]byte, error)
- func (h *Hash32) SetBytes(b []byte)
- func (h Hash32) ShortString() string
- func (h Hash32) String() string
- func (h Hash32) ToHash20() (h20 Hash20)
- func (h *Hash32) UnmarshalJSON(input []byte) error
- func (h *Hash32) UnmarshalText(input []byte) error
- type InnerActivationTx
- type InnerBallot
- type InnerBlock
- type InnerProposal
- type Layer
- func (l *Layer) AddBallot(b *Ballot)
- func (l *Layer) AddBlock(b *Block)
- func (l *Layer) BallotIDs() []BallotID
- func (l *Layer) Ballots() []*Ballot
- func (l *Layer) Blocks() []*Block
- func (l *Layer) BlocksIDs() []BlockID
- func (l *Layer) Field() log.Field
- func (l *Layer) Index() LayerID
- func (l *Layer) SetBallots(ballots []*Ballot)
- func (l *Layer) SetBlocks(blocks []*Block)
- type LayerID
- func (l LayerID) Add(layers uint32) LayerID
- func (l LayerID) After(other LayerID) bool
- func (l LayerID) Before(other LayerID) bool
- func (l LayerID) Bytes() []byte
- func (t *LayerID) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (l LayerID) Difference(other LayerID) uint32
- func (t *LayerID) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (l LayerID) Field() log.Field
- func (l LayerID) FirstInEpoch() bool
- func (l LayerID) GetEpoch() EpochID
- func (l LayerID) Mul(layers uint32) LayerID
- func (l LayerID) OrdinalInEpoch() uint32
- func (l LayerID) String() string
- func (l LayerID) Sub(layers uint32) LayerID
- func (l LayerID) Uint32() uint32
- type LayerLimits
- type MalfeasanceGossip
- type MalfeasanceProof
- type MeshTransaction
- type NIPost
- type NIPostBuilderState
- type NIPostChallenge
- func (t *NIPostChallenge) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *NIPostChallenge) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (challenge *NIPostChallenge) Hash() Hash32
- func (c *NIPostChallenge) MarshalLogObject(encoder log.ObjectEncoder) error
- func (challenge *NIPostChallenge) PublishEpoch() EpochID
- func (challenge *NIPostChallenge) String() string
- func (challenge *NIPostChallenge) TargetEpoch() EpochID
- type NodeID
- type Nonce
- type Opinion
- type PoetChallenge
- type PoetProof
- type PoetProofMessage
- func (t *PoetProofMessage) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *PoetProofMessage) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (p *PoetProofMessage) MarshalLogObject(encoder log.ObjectEncoder) error
- func (proofMessage *PoetProofMessage) Ref() (PoetProofRef, error)
- type PoetProofRef
- type PoetRequest
- type PoetRound
- type PoetServiceID
- type Post
- type PostMetadata
- type ProcessingError
- type Proof
- type Proposal
- func (p *Proposal) Bytes() []byte
- func (t *Proposal) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *Proposal) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (p *Proposal) ID() ProposalID
- func (p *Proposal) Initialize() error
- func (p *Proposal) MarshalLogObject(encoder log.ObjectEncoder) error
- func (p *Proposal) SetID(pid ProposalID)
- type ProposalID
- func (id ProposalID) AsHash32() Hash32
- func (id ProposalID) Bytes() []byte
- func (id ProposalID) Compare(other ProposalID) bool
- func (id *ProposalID) DecodeScale(d *scale.Decoder) (int, error)
- func (id *ProposalID) EncodeScale(e *scale.Encoder) (int, error)
- func (id ProposalID) Field() log.Field
- func (id ProposalID) String() string
- type RatNum
- type RatVar
- type RawTx
- type Reward
- type RoundEnd
- type RoundID
- type TXState
- type Transaction
- func (t *Transaction) DecodeScale(dec *scale.Decoder) (total int, err error)
- func (t *Transaction) EncodeScale(enc *scale.Encoder) (total int, err error)
- func (t Transaction) GetRaw() RawTx
- func (t *Transaction) Hash32() Hash32
- func (t *Transaction) ShortString() string
- func (t Transaction) Verified() bool
- type TransactionID
- func (id TransactionID) Bytes() []byte
- func (id TransactionID) Compare(other TransactionID) bool
- func (id *TransactionID) DecodeScale(d *scale.Decoder) (int, error)
- func (id *TransactionID) EncodeScale(e *scale.Encoder) (int, error)
- func (id TransactionID) Field() log.Field
- func (id TransactionID) Hash32() Hash32
- func (id TransactionID) ShortString() string
- func (id TransactionID) String() string
- type TransactionResult
- type TransactionStatus
- type TransactionWithResult
- type TxHeader
- type VRFPostIndex
- type VerifiedActivationTx
- func (vatx *VerifiedActivationTx) BaseTickHeight() uint64
- func (vatx *VerifiedActivationTx) GetWeight() uint64
- func (vatx *VerifiedActivationTx) MarshalLogObject(encoder log.ObjectEncoder) error
- func (vatx *VerifiedActivationTx) TickCount() uint64
- func (vatx *VerifiedActivationTx) TickHeight() uint64
- type Vote
- type Votes
- type VotingEligibility
Constants ¶
const ( // AddressLength is the expected length of the address. AddressLength = 24 // AddressReservedSpace define how much bytes from top is reserved in address for future. AddressReservedSpace = 4 )
const ( // LayerIDSize in bytes. LayerIDSize = 4 // BootstrapBeacon is the hex value of the beacon used during genesis. // TODO: make this a config. BootstrapBeacon = "0x333c04dd151a2a6831c039cb9a651df29198be8a04e16ce861d4b6a34a11c954" // sha256("bootstrap") )
const ( MultipleATXs byte = iota + 1 MultipleBallots HareEquivocation )
const ( // ATXIDSize in bytes. ATXIDSize = Hash32Length )
const ( // BallotIDSize in bytes. // FIXME(dshulyak) why do we cast to hash32 when returning bytes? BallotIDSize = Hash32Length )
const (
// BeaconSize in bytes.
BeaconSize = 4
)
const ( // BlockIDSize in bytes. // FIXME(dshulyak) why do we cast to hash32 when returning bytes? // probably required for fetching by hash between peers. BlockIDSize = Hash32Length )
const ( // FirstRound is convenient for initializing the index in a loop. FirstRound = RoundID(0) )
const (
// Hash32Length is 32, the expected length of the hash.
Hash32Length = 32
)
const ( // NodeIDSize in bytes. NodeIDSize = Hash32Length )
const ( // ProposalIDSize in bytes. // FIXME(dshulyak) why do we cast to hash32 when returning bytes? // probably required for fetching by hash between peers. ProposalIDSize = Hash32Length )
const ( // TransactionIDSize in bytes. TransactionIDSize = Hash32Length )
Variables ¶
var ( // ErrWrongAddressLength is returned when the length of the address is not correct. ErrWrongAddressLength = errors.New("wrong address length") // ErrUnsupportedNetwork is returned when a network is not supported. ErrUnsupportedNetwork = errors.New("unsupported network") // ErrDecodeBech32 is returned when an error occurs during decoding bech32. ErrDecodeBech32 = errors.New("error decoding bech32") // ErrMissingReservedSpace is returned if top bytes of address is not 0. ErrMissingReservedSpace = errors.New("missing reserved space") )
var EmptyATXID = &ATXID{}
EmptyATXID is a canonical empty ATXID.
var EmptyBallotID = BallotID{}
EmptyBallotID is a canonical empty BallotID.
var EmptyBeacon = Beacon{}
EmptyBeacon is a canonical empty Beacon.
var EmptyBlockID = BlockID{}
EmptyBlockID is a canonical empty BlockID.
var ( // EmptyLayerHash is the layer hash for an empty layer. EmptyLayerHash = Hash32{} )
var EmptyProposalID = ProposalID{}
EmptyProposalID is a canonical empty ProposalID.
var ExtractNodeIDFromSig = func(msg, sig []byte) (NodeID, error) { pub, err := ed25519.ExtractPublicKey(msg, sig) if err != nil { return NodeID{}, err } return BytesToNodeID(pub), nil }
ExtractNodeIDFromSig extracts the NodeID from a signature.
TODO(mafa): this is a hack because the common/types package is not able to import the signing package. The proper fix for this would be to move code that calls this function out of the common/types package.
Functions ¶
func BlockIdsField ¶ added in v1.0.0
BlockIdsField returns a list of loggable fields for a given list of BlockID.
func GetLayersPerEpoch ¶ added in v1.0.0
func GetLayersPerEpoch() uint32
GetLayersPerEpoch returns number of layers per epoch.
func IsProcessingError ¶
IsProcessingError returns true if the given error is a processing error.
func RandomBytes ¶ added in v1.0.0
RandomBytes generates random data in bytes for testing.
func SetLayersPerEpoch ¶ added in v0.1.15
func SetLayersPerEpoch(layers uint32)
SetLayersPerEpoch sets global parameter of layers per epoch, all conversions from layer to epoch use this param.
func TxIdsField ¶ added in v0.1.15
func TxIdsField(ids []TransactionID) log.Field
TxIdsField returns a list of loggable fields for a given list of IDs.
Types ¶
type ATXID ¶ added in v0.1.11
type ATXID Hash32
ATXID is a 32-bit hash used to identify an activation transaction.
func RandomATXID ¶ added in v1.0.0
func RandomATXID() ATXID
RandomATXID generates a random ATXID for testing.
func RandomActiveSet ¶ added in v1.0.0
RandomActiveSet generates a random set of ATXIDs of the specified size.
func SortAtxIDs ¶ added in v0.1.15
SortAtxIDs sorts a list of atx IDs in lexicographic order, in-place.
func ToATXIDs ¶ added in v1.0.0
func ToATXIDs(atxs []*ActivationTx) []ATXID
ToATXIDs returns a slice of ATXID corresponding to the given activation tx.
func (*ATXID) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*ATXID) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
func (ATXID) Field ¶ added in v0.1.11
Field returns a log field. Implements the LoggableField interface.
func (ATXID) Less ¶
Less returns true if other (the given ATXID) is less than this ATXID, by lexicographic comparison.
func (ATXID) ShortString ¶ added in v0.1.11
ShortString returns the first few characters of the ID, for logging purposes.
type ATXMetadata ¶ added in v1.0.0
ATXMetadata is the signed data of ActivationTx.
func (*ATXMetadata) DecodeScale ¶ added in v1.0.0
func (t *ATXMetadata) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*ATXMetadata) EncodeScale ¶ added in v1.0.0
func (t *ATXMetadata) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*ATXMetadata) MarshalLogObject ¶ added in v1.0.0
func (m *ATXMetadata) MarshalLogObject(encoder log.ObjectEncoder) error
type Account ¶ added in v1.0.0
type Account struct { Layer LayerID Address Address Initialized bool NextNonce uint64 Balance uint64 TemplateAddress *Address State []byte }
Account represents account state at a certain layer.
func (*Account) DecodeScale ¶ added in v1.0.0
func (*Account) EncodeScale ¶ added in v1.0.0
func (*Account) MarshalLogObject ¶ added in v1.0.0
func (a *Account) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements encoding for the account state.
type ActivationTx ¶
type ActivationTx struct { InnerActivationTx ATXMetadata // signature over ATXMetadata Signature []byte }
ActivationTx is a full, signed activation transaction. It includes (or references) everything a miner needs to prove they are eligible to actively participate in the Spacemesh protocol in the next epoch.
func BytesToAtx ¶ added in v0.1.15
func BytesToAtx(b []byte) (*ActivationTx, error)
BytesToAtx deserializes an ActivationTx.
func NewActivationTx ¶
func NewActivationTx( challenge NIPostChallenge, nodeID *NodeID, coinbase Address, nipost *NIPost, numUnits uint32, initialPost *Post, nonce *VRFPostIndex, ) *ActivationTx
NewActivationTx returns a new activation transaction. The ATXID is calculated and cached.
func (*ActivationTx) CalcAndSetID ¶ added in v0.1.11
func (atx *ActivationTx) CalcAndSetID() error
CalcAndSetID calculates and sets the cached ID field. This field must be set before calling the ID() method.
func (*ActivationTx) CalcAndSetNodeID ¶
func (atx *ActivationTx) CalcAndSetNodeID() error
CalcAndSetNodeID calculates and sets the cached Node ID field. This field must be set before calling the NodeID() method.
func (*ActivationTx) DecodeScale ¶ added in v1.0.0
func (t *ActivationTx) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*ActivationTx) EffectiveNumUnits ¶ added in v1.0.0
func (atx *ActivationTx) EffectiveNumUnits() uint32
func (*ActivationTx) EncodeScale ¶ added in v1.0.0
func (t *ActivationTx) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*ActivationTx) GetPoetProofRef ¶
func (atx *ActivationTx) GetPoetProofRef() Hash32
GetPoetProofRef returns the reference to the PoET proof.
func (*ActivationTx) GetShortPoetProofRef ¶
func (atx *ActivationTx) GetShortPoetProofRef() []byte
GetShortPoetProofRef returns the first 5 characters of the PoET proof reference, for logging purposes.
func (*ActivationTx) HashInnerBytes ¶ added in v1.0.0
func (atx *ActivationTx) HashInnerBytes() []byte
HashInnerBytes returns a byte slice of the serialization of the inner ATX (excluding the signature field).
func (*ActivationTx) ID ¶ added in v1.0.0
func (atx *ActivationTx) ID() ATXID
ID returns the ATX's ID.
func (*ActivationTx) MarshalLogObject ¶ added in v1.0.0
func (atx *ActivationTx) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
func (*ActivationTx) NodeID ¶
func (atx *ActivationTx) NodeID() NodeID
NodeID returns the ATX's Node ID.
func (*ActivationTx) Received ¶ added in v1.0.0
func (atx *ActivationTx) Received() time.Time
func (*ActivationTx) SetEffectiveNumUnits ¶ added in v1.0.0
func (atx *ActivationTx) SetEffectiveNumUnits(numUnits uint32)
func (*ActivationTx) SetID ¶ added in v1.0.0
func (atx *ActivationTx) SetID(id *ATXID)
SetID sets the ATXID in this ATX's cache.
func (*ActivationTx) SetMetadata ¶
func (atx *ActivationTx) SetMetadata()
SetMetadata sets ATXMetadata.
func (*ActivationTx) SetNodeID ¶
func (atx *ActivationTx) SetNodeID(nodeID *NodeID)
SetNodeID sets the Node ID in the ATX's cache.
func (*ActivationTx) SetReceived ¶ added in v1.0.0
func (atx *ActivationTx) SetReceived(received time.Time)
func (*ActivationTx) ShortString ¶ added in v1.0.0
func (atx *ActivationTx) ShortString() string
ShortString returns the first 5 characters of the ID, for logging purposes.
func (*ActivationTx) SignedBytes ¶ added in v1.0.0
func (atx *ActivationTx) SignedBytes() []byte
SignedBytes returns a signed data of the ActivationTx.
func (*ActivationTx) Verify ¶ added in v1.0.0
func (atx *ActivationTx) Verify(baseTickHeight, tickCount uint64) (*VerifiedActivationTx, error)
Verify an ATX for a given base TickHeight and TickCount.
type ActivationTxHeader ¶
type ActivationTxHeader struct { NIPostChallenge Coinbase Address // NumUnits holds the count of space units that have been reserved by the node for the // current epoch; a unit represents a configurable amount of data for PoST NumUnits uint32 // EffectiveNumUnits is the minimum of this ATX's NumUnits and the previous ATX's NumUnits // NumUnit decreases become effective immediately, while NumUnit increases become effective one epoch later // This is because the increased PoST size only becomes effective after a PoET proof has // been generated for it, which is published with the next epoch's ATX. EffectiveNumUnits uint32 // VRFNonce is the nonce found during PoST initialization VRFNonce *VRFPostIndex ID ATXID // the ID of the ATX NodeID NodeID // the id of the Node that created the ATX (public key) BaseTickHeight uint64 // TickCount number of ticks performed by PoET; a tick represents a number of sequential // hashes TickCount uint64 Received time.Time }
ActivationTxHeader is the header of an activation transaction. It includes all fields from the NIPostChallenge, as well as the coinbase address and total weight.
func (*ActivationTxHeader) GetWeight ¶ added in v1.0.0
func (atxh *ActivationTxHeader) GetWeight() uint64
GetWeight of the ATX. The total weight of the epoch is expected to fit in a uint64 and is sum(atx.NumUnits * atx.TickCount for each ATX in a given epoch). Space Units sizes are chosen such that NumUnits for all ATXs in an epoch is expected to be < 10^9. PoETs should produce ~10k ticks at genesis, but are expected due to technological advances to produce more over time. A uint64 should be large enough to hold the total weight of an epoch, for at least the first few years.
func (*ActivationTxHeader) TickHeight ¶ added in v1.0.0
func (atxh *ActivationTxHeader) TickHeight() uint64
TickHeight returns a sum of base tick height and tick count.
type Address ¶
type Address [AddressLength]byte
Address represents the address of a spacemesh account with AddressLength length.
func GenerateAddress ¶ added in v1.0.0
GenerateAddress generates an address from a public key.
func StringToAddress ¶
StringToAddress returns a new Address from a given string like `sm1abc...`.
func (*Address) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*Address) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
func (Address) Field ¶ added in v0.1.15
Field returns a log field. Implements the LoggableField interface.
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) GetHRPNetwork ¶ added in v1.0.0
GetHRPNetwork returns the Human-Readable-Part of bech32 addresses for a networkID.
type AddressNonce ¶ added in v1.0.0
AddressNonce is an (address, nonce) named tuple.
type AnyReward ¶ added in v1.0.0
AnyReward contains the reward information.
func (*AnyReward) DecodeScale ¶ added in v1.0.0
func (*AnyReward) EncodeScale ¶ added in v1.0.0
type AtxProof ¶ added in v1.0.0
type AtxProof struct {
Messages [2]AtxProofMsg
}
func (*AtxProof) DecodeScale ¶ added in v1.0.0
func (*AtxProof) EncodeScale ¶ added in v1.0.0
func (*AtxProof) MarshalLogObject ¶ added in v1.0.0
func (ap *AtxProof) MarshalLogObject(encoder log.ObjectEncoder) error
type AtxProofMsg ¶ added in v1.0.0
type AtxProofMsg struct { InnerMsg ATXMetadata Signature []byte }
func (*AtxProofMsg) DecodeScale ¶ added in v1.0.0
func (t *AtxProofMsg) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*AtxProofMsg) EncodeScale ¶ added in v1.0.0
func (t *AtxProofMsg) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*AtxProofMsg) SignedBytes ¶ added in v1.0.0
func (m *AtxProofMsg) SignedBytes() []byte
SignedBytes returns the actual data being signed in a AtxProofMsg.
type Ballot ¶ added in v1.0.0
type Ballot struct { // BallotMetadata is the signed part of the ballot. BallotMetadata InnerBallot // smesher's signature on InnerBallot Signature []byte // Votes field is not signed. Votes Votes // the proof of the smesher's eligibility to vote and propose block content in this epoch. // Eligibilities must be produced in the ascending order. EligibilityProofs []VotingEligibility // contains filtered or unexported fields }
Ballot contains the smesher's signed vote on the mesh history.
func NewExistingBallot ¶ added in v1.0.0
func NewExistingBallot(id BallotID, sig []byte, nodeId NodeID, meta BallotMetadata) Ballot
NewExistingBallot creates ballot from stored data.
func RandomBallot ¶ added in v1.0.0
func RandomBallot() *Ballot
RandomBallot generates a Ballot with random content for testing.
func (*Ballot) DecodeScale ¶ added in v1.0.0
func (*Ballot) EncodeScale ¶ added in v1.0.0
func (*Ballot) HashInnerBytes ¶ added in v1.0.0
HashInnerBytes returns the hash of the InnerBallot.
func (*Ballot) Initialize ¶ added in v1.0.0
Initialize calculates and sets the Ballot's cached ballotID and smesherID. this should be called once all the other fields of the Ballot are set.
func (*Ballot) IsMalicious ¶ added in v1.0.0
IsMalicious returns true if ballot is malicious.
func (*Ballot) MarshalLogObject ¶ added in v1.0.0
func (b *Ballot) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging encoder for Ballot.
func (*Ballot) SetMalicious ¶ added in v1.0.0
func (b *Ballot) SetMalicious()
SetMalicious sets ballot as malicious.
func (*Ballot) SetSmesherID ¶
SetSmesherID from stored data.
func (*Ballot) SignedBytes ¶ added in v1.0.0
SignedBytes returns the serialization of the BallotMetadata for signing.
type BallotID ¶ added in v1.0.0
type BallotID Hash20
BallotID is a 20-byte blake3 sum of the serialized ballot used to identify a Ballot.
func RandomBallotID ¶ added in v1.0.0
func RandomBallotID() BallotID
RandomBallotID generates a random BallotID for testing.
func ToBallotIDs ¶ added in v1.0.0
ToBallotIDs turns a list of Ballot into a list of BallotID.
func (BallotID) AsHash32 ¶ added in v1.0.0
AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this BallotID, it is right-padded with zeros.
func (BallotID) Compare ¶ added in v1.0.0
Compare returns true if other (the given BallotID) is less than this BallotID, by lexicographic comparison.
func (*BallotID) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*BallotID) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
type BallotMetadata ¶ added in v1.0.0
type BallotMetadata struct { // the layer ID in which this ballot is eligible for. this will be validated via EligibilityProof Layer LayerID // hash of InnerBallot MsgHash Hash32 }
BallotMetadata is the signed part of Ballot.
func (*BallotMetadata) DecodeScale ¶ added in v1.0.0
func (t *BallotMetadata) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*BallotMetadata) EncodeScale ¶ added in v1.0.0
func (t *BallotMetadata) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*BallotMetadata) MarshalLogObject ¶ added in v1.0.0
func (m *BallotMetadata) MarshalLogObject(encoder log.ObjectEncoder) error
type BallotProof ¶ added in v1.0.0
type BallotProof struct {
Messages [2]BallotProofMsg
}
func (*BallotProof) DecodeScale ¶ added in v1.0.0
func (t *BallotProof) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*BallotProof) EncodeScale ¶ added in v1.0.0
func (t *BallotProof) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*BallotProof) MarshalLogObject ¶ added in v1.0.0
func (bp *BallotProof) MarshalLogObject(encoder log.ObjectEncoder) error
type BallotProofMsg ¶ added in v1.0.0
type BallotProofMsg struct { InnerMsg BallotMetadata Signature []byte }
func (*BallotProofMsg) DecodeScale ¶ added in v1.0.0
func (t *BallotProofMsg) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*BallotProofMsg) EncodeScale ¶ added in v1.0.0
func (t *BallotProofMsg) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*BallotProofMsg) SignedBytes ¶ added in v1.0.0
func (m *BallotProofMsg) SignedBytes() []byte
SignedBytes returns the actual data being signed in a BallotProofMsg.
type Beacon ¶ added in v1.0.0
type Beacon [BeaconSize]byte
Beacon defines the beacon value. A beacon is generated once per epoch and is used to - verify smesher's VRF signature for proposal/ballot eligibility - determine good ballots in verifying tortoise.
func BytesToBeacon ¶ added in v1.0.0
BytesToBeacon sets the first BeaconSize bytes of b to the Beacon's data.
func HexToBeacon ¶ added in v1.0.0
HexToBeacon sets byte representation of s to a Beacon.
func RandomBeacon ¶ added in v1.0.0
func RandomBeacon() Beacon
RandomBeacon generates random beacon in bytes for testing.
func (Beacon) Field ¶ added in v1.0.0
Field returns a log field. Implements the LoggableField interface.
func (Beacon) ShortString ¶ added in v1.0.0
ShortString returns the first 5 characters of the Beacon, usually for logging purposes.
type Block ¶
type Block struct { InnerBlock // contains filtered or unexported fields }
Block contains the content of a layer on the mesh history.
func NewExistingBlock ¶
func NewExistingBlock(id BlockID, inner InnerBlock) *Block
NewExistingBlock creates a block from existing data.
func (*Block) DecodeScale ¶ added in v1.0.0
func (*Block) EncodeScale ¶ added in v1.0.0
func (*Block) Initialize ¶ added in v0.1.2
func (b *Block) Initialize()
Initialize calculates and sets the Block's cached blockID.
func (*Block) MarshalLogObject ¶ added in v1.0.0
func (b *Block) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging encoder for Block.
type BlockContextualValidity ¶ added in v1.0.0
BlockContextualValidity represents the contextual validity of a block.
type BlockID ¶
type BlockID Hash20
BlockID is a 20-byte blake3 sum of the serialized block used to identify a Block.
func RandomBlockID ¶ added in v0.1.16
func RandomBlockID() BlockID
RandomBlockID generates a random ProposalID for testing.
func SortBlockIDs ¶ added in v0.1.11
func SortBlockIDs(ids blockIDs) []BlockID
SortBlockIDs sorts a list of BlockID in lexicographic order, in-place.
func ToBlockIDs ¶ added in v1.0.0
ToBlockIDs returns a slice of BlockID corresponding to the given list of Block.
func (BlockID) AsHash32 ¶
AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this BlockID, it is right-padded with zeros.
func (BlockID) Compare ¶
Compare returns true if other (the given BlockID) is less than this BlockID, by lexicographic comparison.
func (*BlockID) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*BlockID) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
type Bytes64 ¶
type Bytes64 [64]byte
Bytes64 is 64 byte array.
func (*Bytes64) DecodeScale ¶
DecodeScale implements scale codec interface.
func (*Bytes64) EncodeScale ¶
EncodeScale implements scale codec interface.
type Certificate ¶ added in v1.0.0
type Certificate struct { BlockID BlockID Signatures []CertifyMessage }
Certificate represents a certified block.
func (*Certificate) DecodeScale ¶ added in v1.0.0
func (t *Certificate) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*Certificate) EncodeScale ¶ added in v1.0.0
func (t *Certificate) EncodeScale(enc *scale.Encoder) (total int, err error)
type CertifyContent ¶ added in v1.0.0
type CertifyContent struct { LayerID LayerID BlockID BlockID // EligibilityCnt is the number of eligibility of a NodeID on the given Layer // as a hare output certifier. EligibilityCnt uint16 // Proof is the role proof for being a hare output certifier on the given Layer. Proof []byte }
CertifyContent is actual content the node would sign to certify a hare output.
func (*CertifyContent) DecodeScale ¶ added in v1.0.0
func (t *CertifyContent) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*CertifyContent) EncodeScale ¶ added in v1.0.0
func (t *CertifyContent) EncodeScale(enc *scale.Encoder) (total int, err error)
type CertifyMessage ¶ added in v1.0.0
type CertifyMessage struct { CertifyContent Signature []byte }
CertifyMessage is generated by a node that's eligible to certify the hare output and is gossiped to the network.
func (*CertifyMessage) Bytes ¶ added in v1.0.0
func (cm *CertifyMessage) Bytes() []byte
Bytes returns the actual data being signed in a CertifyMessage.
func (*CertifyMessage) DecodeScale ¶ added in v1.0.0
func (t *CertifyMessage) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*CertifyMessage) EncodeScale ¶ added in v1.0.0
func (t *CertifyMessage) EncodeScale(enc *scale.Encoder) (total int, err error)
type Config ¶
type Config struct {
NetworkHRP string `mapstructure:"network-hrp"`
}
Config is the configuration of the address package.
func DefaultAddressConfig ¶
func DefaultAddressConfig() *Config
DefaultAddressConfig returns the default configuration of the address package.
func DefaultTestAddressConfig ¶
func DefaultTestAddressConfig() *Config
DefaultTestAddressConfig returns the default test configuration of the address package.
type EligibilityType ¶ added in v1.0.0
type EligibilityType uint16
const ( EligibilityBeacon EligibilityType = iota + 1 EligibilityHare EligibilityVoting )
type EpochData ¶ added in v1.0.0
type EpochData struct { // from the smesher's view, the set of ATXs eligible to vote and propose block content in this epoch ActiveSet []ATXID // the beacon value the smesher recorded for this epoch Beacon Beacon }
EpochData contains information that cannot be changed mid-epoch.
func (*EpochData) DecodeScale ¶ added in v1.0.0
func (*EpochData) EncodeScale ¶ added in v1.0.0
type EpochID ¶ added in v0.1.11
type EpochID uint32
EpochID is the running epoch number. It's zero-based, so the genesis epoch has EpochID == 0.
func (EpochID) Field ¶ added in v0.1.11
Field returns a log field. Implements the LoggableField interface.
func (EpochID) FirstLayer ¶ added in v0.1.11
FirstLayer returns the layer ID of the first layer in the epoch.
func (EpochID) IsGenesis ¶ added in v0.1.11
IsGenesis returns true if this epoch is in genesis. The first two epochs are considered genesis epochs.
type HareEligibility ¶ added in v1.0.0
type HareEligibility struct { // VRF signature of EligibilityType, beacon, layer, round Proof []byte // the eligibility count for this layer, round Count uint16 }
HareEligibility includes the required values that, along with the smesher's VRF public key, allow non-interactive eligibility validation for hare round participation.
func (*HareEligibility) DecodeScale ¶ added in v1.0.0
func (t *HareEligibility) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*HareEligibility) EncodeScale ¶ added in v1.0.0
func (t *HareEligibility) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*HareEligibility) MarshalLogObject ¶ added in v1.0.0
func (e *HareEligibility) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
type HareEligibilityGossip ¶ added in v1.0.0
type HareEligibilityGossip struct { Layer LayerID Round uint32 PubKey []byte Eligibility HareEligibility }
func (*HareEligibilityGossip) DecodeScale ¶ added in v1.0.0
func (t *HareEligibilityGossip) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*HareEligibilityGossip) EncodeScale ¶ added in v1.0.0
func (t *HareEligibilityGossip) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*HareEligibilityGossip) MarshalLogObject ¶ added in v1.0.0
func (hg *HareEligibilityGossip) MarshalLogObject(encoder log.ObjectEncoder) error
type HareMetadata ¶ added in v1.0.0
type HareMetadata struct { Layer LayerID // the round counter (K) Round uint32 // hash of hare.Message.InnerMessage MsgHash Hash32 }
func (*HareMetadata) DecodeScale ¶ added in v1.0.0
func (t *HareMetadata) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*HareMetadata) EncodeScale ¶ added in v1.0.0
func (t *HareMetadata) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*HareMetadata) MarshalLogObject ¶ added in v1.0.0
func (hm *HareMetadata) MarshalLogObject(encoder log.ObjectEncoder) error
type HareProof ¶ added in v1.0.0
type HareProof struct {
Messages [2]HareProofMsg
}
func (*HareProof) DecodeScale ¶ added in v1.0.0
func (*HareProof) EncodeScale ¶ added in v1.0.0
func (*HareProof) MarshalLogObject ¶ added in v1.0.0
func (hp *HareProof) MarshalLogObject(encoder log.ObjectEncoder) error
type HareProofMsg ¶ added in v1.0.0
type HareProofMsg struct { InnerMsg HareMetadata Signature []byte }
func (*HareProofMsg) DecodeScale ¶ added in v1.0.0
func (t *HareProofMsg) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*HareProofMsg) EncodeScale ¶ added in v1.0.0
func (t *HareProofMsg) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*HareProofMsg) SignedBytes ¶ added in v1.0.0
func (m *HareProofMsg) SignedBytes() []byte
SignedBytes returns the actual data being signed in a HareProofMsg.
type Hash12 ¶
type Hash12 [hash12Length]byte
Hash12 represents the first 12 bytes of blake3 hash, mostly used for internal caches.
func CalcHash12 ¶
CalcHash12 returns the 12-byte prefix of the blake3 sum of the given byte slice.
func CalcMessageHash12 ¶
CalcMessageHash12 returns the 12-byte blake3 sum of the given msg suffixed with protocol.
type Hash20 ¶
type Hash20 [hash20Length]byte
Hash20 represents the 20-byte blake3 hash of arbitrary data.
func (*Hash20) DecodeScale ¶
DecodeScale implements scale codec interface.
func (Hash20) Field ¶ added in v0.1.2
Field returns a log field. Implements the LoggableField interface.
func (Hash20) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash20) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash20) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash20) ShortString ¶
ShortString returns a the first 5 characters of the hash, for logging purposes.
func (Hash20) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash20) ToHash32 ¶
ToHash32 returns a Hash32 whose first 20 bytes are the bytes of this Hash20, it is right-padded with zeros.
func (*Hash20) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash20) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Hash32 ¶
type Hash32 [Hash32Length]byte
Hash32 represents the 32-byte blake3 hash of arbitrary data.
func ATXIDsToHashes ¶ added in v1.0.0
ATXIDsToHashes turns a list of ATXID into their Hash32 representation.
func BallotIDsToHashes ¶ added in v1.0.0
BallotIDsToHashes turns a list of BallotID into their Hash32 representation.
func BlockIDsToHashes ¶ added in v1.0.0
BlockIDsToHashes turns a list of BlockID into their Hash32 representation.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func CalcBlockHash32Presorted ¶
CalcBlockHash32Presorted returns the 32-byte blake3 sum of the IDs, in the order given. The pre-image is prefixed with additionalBytes.
func CalcBlocksHash32 ¶
CalcBlocksHash32 returns the 32-byte blake3 sum of the IDs, sorted in lexicographic order. The pre-image is prefixed with additionalBytes.
func CalcHash32 ¶
CalcHash32 returns the 32-byte blake3 sum of the given data.
func CalcObjectHash32 ¶ added in v1.0.0
func CalcObjectHash32(obj scale.Encodable) Hash32
CalcObjectHash32 returns the 32-byte blake3 sum of the scale serialization of the object.
func CalcProposalHash32Presorted ¶ added in v1.0.0
func CalcProposalHash32Presorted(sortedView []ProposalID, additionalBytes []byte) Hash32
CalcProposalHash32Presorted returns the 32-byte blake3 sum of the IDs, in the order given. The pre-image is prefixed with additionalBytes.
func CalcProposalsHash32 ¶ added in v1.0.0
func CalcProposalsHash32(view []ProposalID, additionalBytes []byte) Hash32
CalcProposalsHash32 returns the 32-byte blake3 sum of the IDs, sorted in lexicographic order. The pre-image is prefixed with additionalBytes.
func HexToHash32 ¶
HexToHash32 sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func NodeIDsToHashes ¶ added in v1.0.0
NodeIDsToHashes turns a list of NodeID into their Hash32 representation.
func ProposalIDsToHashes ¶ added in v1.0.0
func ProposalIDsToHashes(ids []ProposalID) []Hash32
ProposalIDsToHashes turns a list of ProposalID into their Hash32 representation.
func RandomHash ¶ added in v1.0.0
func RandomHash() Hash32
RandomHash generates random Hash32 for testing.
func TransactionIDsToHashes ¶ added in v1.0.0
func TransactionIDsToHashes(ids []TransactionID) []Hash32
TransactionIDsToHashes turns a list of TransactionID into their Hash32 representation.
func (*Hash32) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*Hash32) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
func (Hash32) Field ¶ added in v0.1.2
Field returns a log field. Implements the LoggableField interface.
func (Hash32) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Hash32) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash32) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash32) ShortString ¶
ShortString returns the first 5 characters of the hash, for logging purposes.
func (Hash32) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (*Hash32) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash32) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type InnerActivationTx ¶
type InnerActivationTx struct { NIPostChallenge Coinbase Address NumUnits uint32 NIPost *NIPost InitialPost *Post VRFNonce *VRFPostIndex // contains filtered or unexported fields }
InnerActivationTx is a set of all of an ATX's fields, except the signature. To generate the ATX signature, this structure is serialized and signed. It includes the header fields, as well as the larger fields that are only used for validation: the NIPost and the initial Post.
func (*InnerActivationTx) DecodeScale ¶ added in v1.0.0
func (t *InnerActivationTx) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*InnerActivationTx) EncodeScale ¶ added in v1.0.0
func (t *InnerActivationTx) EncodeScale(enc *scale.Encoder) (total int, err error)
type InnerBallot ¶ added in v1.0.0
type InnerBallot struct { // the smesher's ATX in the epoch this ballot is cast. AtxID ATXID // OpinionHash is a aggregated opinion on all previous layers. // It is included into transferred data explicitly, so that signature // can be verified before decoding votes. OpinionHash Hash32 // the first Ballot the smesher cast in the epoch. this Ballot is a special Ballot that contains information // that cannot be changed mid-epoch. RefBallot BallotID EpochData *EpochData }
InnerBallot contains all info about a smesher's votes on the mesh history. this structure is serialized and signed to produce the signature in Ballot.
func (*InnerBallot) DecodeScale ¶ added in v1.0.0
func (t *InnerBallot) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*InnerBallot) EncodeScale ¶ added in v1.0.0
func (t *InnerBallot) EncodeScale(enc *scale.Encoder) (total int, err error)
type InnerBlock ¶ added in v1.0.0
type InnerBlock struct { LayerIndex LayerID TickHeight uint64 Rewards []AnyReward TxIDs []TransactionID }
InnerBlock contains the transactions and rewards of a block.
func (*InnerBlock) DecodeScale ¶ added in v1.0.0
func (t *InnerBlock) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*InnerBlock) EncodeScale ¶ added in v1.0.0
func (t *InnerBlock) EncodeScale(enc *scale.Encoder) (total int, err error)
type InnerProposal ¶ added in v1.0.0
type InnerProposal struct { // smesher's votes on the mesh history Ballot // smesher's content proposal for a layer TxIDs []TransactionID // aggregated hash up to the layer before this proposal. MeshHash Hash32 }
InnerProposal contains a smesher's content proposal for layer and its votes on the mesh history. this structure is serialized and signed to produce the signature in Proposal.
func (*InnerProposal) DecodeScale ¶ added in v1.0.0
func (t *InnerProposal) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*InnerProposal) EncodeScale ¶ added in v1.0.0
func (t *InnerProposal) EncodeScale(enc *scale.Encoder) (total int, err error)
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer contains a list of proposals and their corresponding LayerID.
func NewExistingLayer ¶
NewExistingLayer returns a new layer with the given list of blocks without validation.
func (*Layer) AddBallot ¶ added in v1.0.0
AddBallot adds a ballot to this layer. Panics if the ballot's index doesn't match the layer.
func (*Layer) AddBlock ¶
AddBlock adds a block to this layer. Panics if the block's index doesn't match the layer.
func (*Layer) BallotIDs ¶ added in v1.0.0
BallotIDs returns the list of IDs for ballots in this layer.
func (*Layer) BlocksIDs ¶ added in v1.0.0
BlocksIDs returns the list of IDs for blocks in this layer.
func (*Layer) Field ¶ added in v0.1.15
Field returns a log field. Implements the LoggableField interface.
func (*Layer) SetBallots ¶ added in v1.0.0
SetBallots sets the list of ballots for the layer without validation.
type LayerID ¶
type LayerID struct { // NOTE(dshulyak) it is made public for compatibility with encoding library. // Don't modify it directly, as it will likely to be made private in the future. Value uint32 }
LayerID is representing a layer number. Zero value is safe to use, and means 0. Internally it is a simple wrapper over uint32 and should be considered immutable the same way as any integer.
func GetEffectiveGenesis ¶ added in v0.1.15
func GetEffectiveGenesis() LayerID
GetEffectiveGenesis returns when actual proposals would be created.
func (LayerID) Bytes ¶ added in v0.1.15
Bytes returns the byte representation of the LayerID, using little endian encoding.
func (*LayerID) DecodeScale ¶ added in v1.0.0
func (LayerID) Difference ¶ added in v1.0.0
Difference returns the difference between current and other layer.
func (*LayerID) EncodeScale ¶ added in v1.0.0
func (LayerID) Field ¶ added in v0.1.2
Field returns a log field. Implements the LoggableField interface.
func (LayerID) FirstInEpoch ¶ added in v1.0.0
FirstInEpoch returns whether this LayerID is first in epoch.
func (LayerID) OrdinalInEpoch ¶ added in v1.0.0
OrdinalInEpoch returns layer ordinal in epoch.
func (LayerID) String ¶ added in v1.0.0
String returns string representation of the layer id numeric value.
type LayerLimits ¶ added in v1.0.0
type LayerLimits struct {
Min, Max uint32
}
LayerLimits if defined restricts in what layers transaction may be applied.
func (*LayerLimits) DecodeScale ¶ added in v1.0.0
func (t *LayerLimits) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*LayerLimits) EncodeScale ¶ added in v1.0.0
func (t *LayerLimits) EncodeScale(enc *scale.Encoder) (total int, err error)
type MalfeasanceGossip ¶ added in v1.0.0
type MalfeasanceGossip struct { MalfeasanceProof Eligibility *HareEligibilityGossip // optional, only useful in live hare rounds }
func (*MalfeasanceGossip) DecodeScale ¶ added in v1.0.0
func (t *MalfeasanceGossip) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*MalfeasanceGossip) EncodeScale ¶ added in v1.0.0
func (t *MalfeasanceGossip) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*MalfeasanceGossip) MarshalLogObject ¶ added in v1.0.0
func (mg *MalfeasanceGossip) MarshalLogObject(encoder log.ObjectEncoder) error
type MalfeasanceProof ¶ added in v1.0.0
func (*MalfeasanceProof) DecodeScale ¶ added in v1.0.0
func (t *MalfeasanceProof) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*MalfeasanceProof) EncodeScale ¶ added in v1.0.0
func (t *MalfeasanceProof) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*MalfeasanceProof) MarshalLogObject ¶ added in v1.0.0
func (mp *MalfeasanceProof) MarshalLogObject(encoder log.ObjectEncoder) error
type MeshTransaction ¶ added in v1.0.0
type MeshTransaction struct { Transaction LayerID LayerID BlockID BlockID State TXState Received time.Time }
MeshTransaction is stored in the mesh and included in the block.
type NIPost ¶ added in v1.0.0
type NIPost struct { // Challenge is the challenge for the PoET which is // constructed from fields in the activation transaction. Challenge *Hash32 // Post is the proof that the prover data is still stored (or was recomputed) at // the time he learned the challenge constructed from the PoET. Post *Post // PostMetadata is the Post metadata, associated with the proof. // The proof should be verified upon the metadata during the syntactic validation, // while the metadata should be verified during the contextual validation. PostMetadata *PostMetadata }
NIPost is Non-Interactive Proof of Space-Time. Given an id, a space parameter S, a duration D and a challenge C, it can convince a verifier that (1) the prover expended S * D space-time after learning the challenge C. (2) the prover did not know the NIPost until D time after the prover learned C.
func (*NIPost) DecodeScale ¶ added in v1.0.0
func (*NIPost) EncodeScale ¶ added in v1.0.0
type NIPostBuilderState ¶ added in v1.0.0
type NIPostBuilderState struct { Challenge Hash32 NIPost *NIPost PoetRequests []PoetRequest // PoetProofRef is the root of the proof received from the PoET service. PoetProofRef PoetProofRef }
NIPostBuilderState is a builder state.
func (*NIPostBuilderState) DecodeScale ¶ added in v1.0.0
func (t *NIPostBuilderState) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*NIPostBuilderState) EncodeScale ¶ added in v1.0.0
func (t *NIPostBuilderState) EncodeScale(enc *scale.Encoder) (total int, err error)
type NIPostChallenge ¶ added in v1.0.0
type NIPostChallenge struct { PubLayerID LayerID // Sequence number counts the number of ancestors of the ATX. It sequentially increases for each ATX in the chain. // Two ATXs with the same sequence number from the same miner can be used as the proof of malfeasance against that miner. Sequence uint64 PrevATXID ATXID PositioningATX ATXID // CommitmentATX is the ATX used in the commitment for initializing the PoST of the node. CommitmentATX *ATXID InitialPostIndices []byte }
NIPostChallenge is the set of fields that's serialized, hashed and submitted to the PoET service to be included in the PoET membership proof. It includes ATX sequence number, the previous ATX's ID (for all but the first in the sequence), the intended publication layer ID, the PoET's start and end ticks, the positioning ATX's ID and for the first ATX in the sequence also the commitment Merkle root.
func (*NIPostChallenge) DecodeScale ¶ added in v1.0.0
func (t *NIPostChallenge) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*NIPostChallenge) EncodeScale ¶ added in v1.0.0
func (t *NIPostChallenge) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*NIPostChallenge) Hash ¶ added in v1.0.0
func (challenge *NIPostChallenge) Hash() Hash32
Hash serializes the NIPostChallenge and returns its hash.
func (*NIPostChallenge) MarshalLogObject ¶ added in v1.0.0
func (c *NIPostChallenge) MarshalLogObject(encoder log.ObjectEncoder) error
func (*NIPostChallenge) PublishEpoch ¶ added in v1.0.0
func (challenge *NIPostChallenge) PublishEpoch() EpochID
PublishEpoch returns the publishing epoch of the NIPostChallenge.
func (*NIPostChallenge) String ¶ added in v1.0.0
func (challenge *NIPostChallenge) String() string
String returns a string representation of the NIPostChallenge, for logging purposes. It implements the Stringer interface.
func (*NIPostChallenge) TargetEpoch ¶ added in v1.0.0
func (challenge *NIPostChallenge) TargetEpoch() EpochID
TargetEpoch returns the target epoch of the NIPostChallenge. This is the epoch in which the miner is eligible to participate thanks to the ATX.
type NodeID ¶ added in v0.1.11
type NodeID Hash32
NodeID contains a miner's public key.
var EmptyNodeID NodeID
EmptyNodeID is a canonical empty NodeID.
func BytesToNodeID ¶ added in v0.1.28
BytesToNodeID is a helper to copy buffer into NodeID struct.
func RandomNodeID ¶ added in v1.0.0
func RandomNodeID() NodeID
RandomNodeID generates a random NodeID for testing.
func (NodeID) Bytes ¶ added in v1.0.0
Bytes returns the byte representation of the Edwards public key.
func (*NodeID) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*NodeID) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
func (NodeID) Field ¶ added in v0.1.11
Field returns a log field. Implements the LoggableField interface.
func (NodeID) ShortString ¶ added in v0.1.11
ShortString returns a the first 5 characters of the ID, for logging purposes.
type Opinion ¶ added in v1.0.0
Opinion is a tuple from opinion hash and votes that decode to opinion hash.
func (*Opinion) DecodeScale ¶ added in v1.0.0
func (*Opinion) EncodeScale ¶ added in v1.0.0
func (*Opinion) MarshalLogObject ¶ added in v1.0.0
func (o *Opinion) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
type PoetChallenge ¶ added in v1.0.0
type PoetChallenge struct { *NIPostChallenge InitialPost *Post InitialPostMetadata *PostMetadata NumUnits uint32 }
func (*PoetChallenge) DecodeScale ¶ added in v1.0.0
func (t *PoetChallenge) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*PoetChallenge) EncodeScale ¶ added in v1.0.0
func (t *PoetChallenge) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*PoetChallenge) MarshalLogObject ¶ added in v1.0.0
func (c *PoetChallenge) MarshalLogObject(encoder log.ObjectEncoder) error
type PoetProof ¶
type PoetProof struct { poetShared.MerkleProof Members [][]byte LeafCount uint64 }
PoetProof is the full PoET service proof of elapsed time. It includes the list of members, a leaf count declaration and the actual PoET Merkle proof.
func (*PoetProof) DecodeScale ¶ added in v1.0.0
func (*PoetProof) EncodeScale ¶ added in v1.0.0
func (*PoetProof) MarshalLogObject ¶ added in v1.0.0
func (p *PoetProof) MarshalLogObject(encoder log.ObjectEncoder) error
type PoetProofMessage ¶
PoetProofMessage is the envelope which includes the PoetProof, service ID, round ID and signature.
func (*PoetProofMessage) DecodeScale ¶ added in v1.0.0
func (t *PoetProofMessage) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*PoetProofMessage) EncodeScale ¶ added in v1.0.0
func (t *PoetProofMessage) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*PoetProofMessage) MarshalLogObject ¶ added in v1.0.0
func (p *PoetProofMessage) MarshalLogObject(encoder log.ObjectEncoder) error
func (*PoetProofMessage) Ref ¶
func (proofMessage *PoetProofMessage) Ref() (PoetProofRef, error)
Ref returns the reference to the PoET proof message. It's the blake3 sum of the entire proof message.
type PoetProofRef ¶ added in v1.0.0
type PoetProofRef []byte
type PoetRequest ¶ added in v1.0.0
type PoetRequest struct { // PoetRound is the round of the PoET proving service in which the PoET challenge was included in. PoetRound *PoetRound // PoetServiceID returns the public key of the PoET proving service. PoetServiceID PoetServiceID }
PoetRequest describes an in-flight challenge submission for a poet proof.
func (*PoetRequest) DecodeScale ¶ added in v1.0.0
func (t *PoetRequest) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*PoetRequest) EncodeScale ¶ added in v1.0.0
func (t *PoetRequest) EncodeScale(enc *scale.Encoder) (total int, err error)
type PoetRound ¶
PoetRound includes the PoET's round ID.
func (*PoetRound) DecodeScale ¶ added in v1.0.0
func (*PoetRound) EncodeScale ¶ added in v1.0.0
type PoetServiceID ¶ added in v1.0.0
type PoetServiceID = []byte
type Post ¶ added in v1.0.0
type Post postShared.Proof
Post is an alias to postShared.Proof.
func (*Post) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*Post) EncodeScale ¶ added in v1.0.0
EncodeScale implements scale codec interface.
func (*Post) MarshalLogObject ¶ added in v1.0.0
func (p *Post) MarshalLogObject(encoder log.ObjectEncoder) error
type PostMetadata ¶ added in v1.0.0
type PostMetadata struct { Challenge []byte BitsPerLabel uint8 LabelsPerUnit uint64 K1 uint32 K2 uint32 B uint32 N uint32 }
PostMetadata is similar postShared.ProofMetadata, but without the fields which can be derived elsewhere in a given ATX (ID, NumUnits).
func (*PostMetadata) DecodeScale ¶ added in v1.0.0
func (t *PostMetadata) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*PostMetadata) EncodeScale ¶ added in v1.0.0
func (t *PostMetadata) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*PostMetadata) MarshalLogObject ¶ added in v1.0.0
func (m *PostMetadata) MarshalLogObject(encoder log.ObjectEncoder) error
type ProcessingError ¶
type ProcessingError string
ProcessingError is a type of error (implements the error interface) that is used to differentiate processing errors from validation errors.
func (ProcessingError) Error ¶
func (s ProcessingError) Error() string
Error returns the processing error as a string. It implements the error interface.
type Proof ¶ added in v1.0.0
type Proof struct { // MultipleATXs | MultipleBallots | HareEquivocation Type uint8 // AtxProof | BallotProof | HareProof Data scale.Type }
func (*Proof) DecodeScale ¶ added in v1.0.0
func (*Proof) EncodeScale ¶ added in v1.0.0
type Proposal ¶ added in v1.0.0
type Proposal struct { // the content proposal for a given layer and the votes on the mesh history InnerProposal // smesher's signature on InnerProposal Signature []byte // contains filtered or unexported fields }
Proposal contains the smesher's signed content proposal for a given layer and vote on the mesh history. Proposal is ephemeral and will be discarded after the unified content block is created. the Ballot within the Proposal will remain in the mesh.
func SortProposals ¶ added in v1.0.0
SortProposals sorts a list of Proposal in their ID's lexicographic order, in-place.
func (*Proposal) DecodeScale ¶ added in v1.0.0
func (*Proposal) EncodeScale ¶ added in v1.0.0
func (*Proposal) Initialize ¶ added in v1.0.0
Initialize calculates and sets the Proposal's cached proposalID. this should be called once all the other fields of the Proposal are set.
func (*Proposal) MarshalLogObject ¶ added in v1.0.0
func (p *Proposal) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
func (*Proposal) SetID ¶ added in v1.0.0
func (p *Proposal) SetID(pid ProposalID)
SetID set the ProposalID.
type ProposalID ¶ added in v1.0.0
type ProposalID Hash20
ProposalID is a 20-byte blake3 sum of the serialized ballot used to identify a Proposal.
func RandomProposalID ¶ added in v1.0.0
func RandomProposalID() ProposalID
RandomProposalID generates a random ProposalID for testing.
func SortProposalIDs ¶ added in v1.0.0
func SortProposalIDs(ids []ProposalID) []ProposalID
SortProposalIDs sorts a list of ProposalID in lexicographic order, in-place.
func ToProposalIDs ¶ added in v1.0.0
func ToProposalIDs(proposals []*Proposal) []ProposalID
ToProposalIDs returns a slice of ProposalID corresponding to the given proposals.
func (ProposalID) AsHash32 ¶ added in v1.0.0
func (id ProposalID) AsHash32() Hash32
AsHash32 returns a Hash32 whose first 20 bytes are the bytes of this ProposalID, it is right-padded with zeros.
func (ProposalID) Bytes ¶ added in v1.0.0
func (id ProposalID) Bytes() []byte
Bytes returns the ProposalID as a byte slice.
func (ProposalID) Compare ¶ added in v1.0.0
func (id ProposalID) Compare(other ProposalID) bool
Compare returns true if other (the given ProposalID) is less than this ProposalID, by lexicographic comparison.
func (*ProposalID) DecodeScale ¶ added in v1.0.0
func (id *ProposalID) DecodeScale(d *scale.Decoder) (int, error)
DecodeScale implements scale codec interface.
func (*ProposalID) EncodeScale ¶ added in v1.0.0
func (id *ProposalID) EncodeScale(e *scale.Encoder) (int, error)
EncodeScale implements scale codec interface.
func (ProposalID) Field ¶ added in v1.0.0
func (id ProposalID) Field() log.Field
Field returns a log field. Implements the LoggableField interface.
func (ProposalID) String ¶ added in v1.0.0
func (id ProposalID) String() string
String returns a short prefix of the hex representation of the ID.
type RatNum ¶ added in v1.0.0
type RatNum struct {
Num, Denom uint64
}
RatNum represents a rational number with the numerator and denominator. note: RatNum aims to be a generic representation of a rational number and parse-able by different programming languages. for doing math around weight inside go-spacemesh codebase, use util.Weight.
func RatNumFromBigRat ¶ added in v1.0.0
func (*RatNum) DecodeScale ¶ added in v1.0.0
func (*RatNum) EncodeScale ¶ added in v1.0.0
type RatVar ¶ added in v1.0.0
RatVar is a wrapper for big.Rat to use it with the pflag package.
type RawTx ¶ added in v1.0.0
type RawTx struct { ID TransactionID Raw []byte }
RawTx stores an identity and a pointer to raw bytes.
func (*RawTx) DecodeScale ¶ added in v1.0.0
func (*RawTx) EncodeScale ¶ added in v1.0.0
type Reward ¶
Reward is a virtual reward transaction, which the node keeps track of for the gRPC api.
func (*Reward) DecodeScale ¶ added in v1.0.0
func (*Reward) EncodeScale ¶ added in v1.0.0
type RoundEnd ¶ added in v1.0.0
func (*RoundEnd) DecodeScale ¶ added in v1.0.0
DecodeScale implements scale codec interface.
func (*RoundEnd) EncodeScale ¶ added in v1.0.0
type RoundID ¶ added in v1.0.0
type RoundID uint32
RoundID is the round ID used to run any protocol that requires multiple rounds.
type TXState ¶ added in v1.0.0
type TXState uint32
TXState describes the state of a transaction.
const ( // PENDING represents the state when a transaction is syntactically valid, but its nonce and // the principal's ability to cover gas have not been verified yet. PENDING TXState = iota // MEMPOOL represents the state when a transaction is in mempool. MEMPOOL // APPLIED represents the state when a transaction is applied to the state. APPLIED )
type Transaction ¶
Transaction is an alias to RawTx.
func (*Transaction) DecodeScale ¶ added in v1.0.0
func (t *Transaction) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*Transaction) EncodeScale ¶ added in v1.0.0
func (t *Transaction) EncodeScale(enc *scale.Encoder) (total int, err error)
func (Transaction) GetRaw ¶ added in v1.0.0
func (t Transaction) GetRaw() RawTx
GetRaw returns raw bytes of the transaction with id.
func (*Transaction) Hash32 ¶
func (t *Transaction) Hash32() Hash32
Hash32 returns the TransactionID as a Hash32.
func (*Transaction) ShortString ¶
func (t *Transaction) ShortString() string
ShortString returns the first 5 characters of the ID, for logging purposes.
func (Transaction) Verified ¶ added in v1.0.0
func (t Transaction) Verified() bool
Verified returns true if header is set.
type TransactionID ¶ added in v0.1.11
type TransactionID Hash32
TransactionID is a 32-byte blake3 sum of the transaction, used as an identifier.
func RandomTXSet ¶ added in v1.0.0
func RandomTXSet(size int) []TransactionID
RandomTXSet generates a random set of TransactionID of the specified size.
func RandomTransactionID ¶ added in v1.0.0
func RandomTransactionID() TransactionID
RandomTransactionID generates a random TransactionID for testing.
func SortTransactionIDs ¶ added in v1.0.0
func SortTransactionIDs(ids []TransactionID) []TransactionID
SortTransactionIDs sorts a list of TransactionID in their lexicographic order, in-place.
func ToTransactionIDs ¶ added in v1.0.0
func ToTransactionIDs(txs []*Transaction) []TransactionID
ToTransactionIDs returns a slice of TransactionID corresponding to the given transactions.
func (TransactionID) Bytes ¶ added in v0.1.11
func (id TransactionID) Bytes() []byte
Bytes returns the TransactionID as a byte slice.
func (TransactionID) Compare ¶ added in v1.0.0
func (id TransactionID) Compare(other TransactionID) bool
Compare returns true if other (the given TransactionID) is less than this TransactionID, by lexicographic comparison.
func (*TransactionID) DecodeScale ¶ added in v1.0.0
func (id *TransactionID) DecodeScale(d *scale.Decoder) (int, error)
DecodeScale implements scale codec interface.
func (*TransactionID) EncodeScale ¶ added in v1.0.0
func (id *TransactionID) EncodeScale(e *scale.Encoder) (int, error)
EncodeScale implements scale codec interface.
func (TransactionID) Field ¶ added in v0.1.11
func (id TransactionID) Field() log.Field
Field returns a log field. Implements the LoggableField interface.
func (TransactionID) Hash32 ¶ added in v0.1.11
func (id TransactionID) Hash32() Hash32
Hash32 returns the TransactionID as a Hash32.
func (TransactionID) ShortString ¶ added in v0.1.11
func (id TransactionID) ShortString() string
ShortString returns a the first 10 characters of the ID, for logging purposes.
func (TransactionID) String ¶ added in v0.1.11
func (id TransactionID) String() string
String returns a hexadecimal representation of the TransactionID with "0x" prepended, for logging purposes. It implements the fmt.Stringer interface.
type TransactionResult ¶ added in v1.0.0
type TransactionResult struct { Status TransactionStatus Message string Gas uint64 Fee uint64 Block BlockID Layer LayerID // Addresses contains all updated addresses. // For genesis this will be either one or two addresses. Addresses []Address }
TransactionResult is created after consuming transaction.
func (*TransactionResult) DecodeScale ¶ added in v1.0.0
func (t *TransactionResult) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*TransactionResult) EncodeScale ¶ added in v1.0.0
func (t *TransactionResult) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*TransactionResult) MarshalLogObject ¶ added in v1.0.0
func (h *TransactionResult) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements encoding for the tx result.
type TransactionStatus ¶ added in v1.0.0
type TransactionStatus uint8
TransactionStatus ...
const ( // TransactionSuccess is a status for successfully applied transaction. TransactionSuccess TransactionStatus = iota // TransactionFailure is a status for failed but consumed transaction. TransactionFailure )
func (TransactionStatus) DecodeScale ¶
func (t TransactionStatus) DecodeScale(d *scale.Decoder) (uint8, int, error)
DecodeScale implements scale codec interface.
func (TransactionStatus) EncodeScale ¶
func (t TransactionStatus) EncodeScale(e *scale.Encoder) (int, error)
EncodeScale implements scale codec interface.
func (TransactionStatus) String ¶ added in v1.0.0
func (t TransactionStatus) String() string
String implements human readable repr of the status.
type TransactionWithResult ¶ added in v1.0.0
type TransactionWithResult struct { Transaction TransactionResult }
TransactionWithResult is a transaction with attached result.
func (*TransactionWithResult) DecodeScale ¶ added in v1.0.0
func (t *TransactionWithResult) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*TransactionWithResult) EncodeScale ¶ added in v1.0.0
func (t *TransactionWithResult) EncodeScale(enc *scale.Encoder) (total int, err error)
type TxHeader ¶ added in v1.0.0
type TxHeader struct { Principal Address TemplateAddress Address Method uint8 Nonce Nonce LayerLimits LayerLimits MaxGas uint64 GasPrice uint64 MaxSpend uint64 }
TxHeader is a transaction header, with some of the fields defined directly in the tx and the rest is computed by the template based on immutable state and method arguments.
func (*TxHeader) DecodeScale ¶ added in v1.0.0
func (*TxHeader) EncodeScale ¶ added in v1.0.0
func (*TxHeader) MarshalLogObject ¶ added in v1.0.0
func (h *TxHeader) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements encoding for the tx header.
type VRFPostIndex ¶ added in v1.0.0
type VRFPostIndex uint64
VRFPostIndex is the nonce generated using Pow during post initialization. It is used as a mitigation for grinding of identities for VRF eligibility.
func (*VRFPostIndex) DecodeScale ¶ added in v1.0.0
func (v *VRFPostIndex) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*VRFPostIndex) EncodeScale ¶ added in v1.0.0
func (v *VRFPostIndex) EncodeScale(enc *scale.Encoder) (total int, err error)
func (VRFPostIndex) Field ¶ added in v1.0.0
func (v VRFPostIndex) Field() log.Field
Field returns a log field. Implements the LoggableField interface.
type VerifiedActivationTx ¶ added in v1.0.0
type VerifiedActivationTx struct { *ActivationTx // contains filtered or unexported fields }
func (*VerifiedActivationTx) BaseTickHeight ¶ added in v1.0.0
func (vatx *VerifiedActivationTx) BaseTickHeight() uint64
BaseTickHeight is a tick height of the positional atx.
func (*VerifiedActivationTx) GetWeight ¶ added in v1.0.0
func (vatx *VerifiedActivationTx) GetWeight() uint64
GetWeight of the ATX. The total weight of the epoch is expected to fit in a uint64 and is sum(atx.NumUnits * atx.TickCount for each ATX in a given epoch). Space Units sizes are chosen such that NumUnits for all ATXs in an epoch is expected to be < 10^6. PoETs should produce ~10k ticks at genesis, but are expected due to technological advances to produce more over time. A uint64 should be large enough to hold the total weight of an epoch, for at least the first few years.
func (*VerifiedActivationTx) MarshalLogObject ¶ added in v1.0.0
func (vatx *VerifiedActivationTx) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
func (*VerifiedActivationTx) TickCount ¶ added in v1.0.0
func (vatx *VerifiedActivationTx) TickCount() uint64
TickCount returns tick count from poet proof attached to the atx.
func (*VerifiedActivationTx) TickHeight ¶ added in v1.0.0
func (vatx *VerifiedActivationTx) TickHeight() uint64
TickHeight returns a sum of base tick height and tick count.
type Vote ¶ added in v1.0.0
Vote additionally carries layer id and height in order for the tortoise to count votes without downloading block body.
func (*Vote) DecodeScale ¶
func (*Vote) EncodeScale ¶
func (*Vote) MarshalLogObject ¶
func (s *Vote) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
type Votes ¶ added in v1.0.0
type Votes struct { // Base ballot. Base BallotID // Support block id at a particular layer and height. Support []Vote // Against previously supported block. Against []Vote // Abstain on layers until they are terminated. Abstain []LayerID }
Votes is for encoding local votes to send over the wire.
a smesher creates votes in the following steps: - select a Ballot in the past as a base Ballot - calculate the opinion difference on history between the smesher and the base Ballot - encode the opinion difference in 3 list:
- ForDiff contains blocks we support while the base ballot did not support (i.e. voted against) for blocks we support in layers later than the base ballot, we also add them to this list
- AgainstDiff contains blocks we vote against while the base ballot explicitly supported
- NeutralDiff contains layers we vote neutral while the base ballot explicitly supported or voted against
example: layer | unified content block -----------------------------------------------------------------------------------------------
N | UCB_A (genesis)
-----------------------------------------------------------------------------------------------
N+1 | UCB_B base:UCB_A, for:[UCB_A], against:[], neutral:[]
-----------------------------------------------------------------------------------------------
N+2 | UCB_C base:UCB_B, for:[UCB_B], against:[], neutral:[]
-----------------------------------------------------------------------------------------------
(hare hasn't terminated for N+2) N+3 | UCB_D base:UCB_B, for:[UCB_B], against:[], neutral:[N+2]
-----------------------------------------------------------------------------------------------
(hare succeeded for N+2 but failed for N+3) N+4 | UCB_E base:UCB_C, for:[UCB_C], against:[], neutral:[]
----------------------------------------------------------------------------------------------- NOTE on neutral votes: a base block is by default neutral on all blocks and layers that come after it, so there's no need to explicitly add neutral votes for more recent layers.
TODO: maybe collapse Support and Against into a single list.
see https://github.com/spacemeshos/go-spacemesh/issues/2369.
func (*Votes) DecodeScale ¶ added in v1.0.0
func (*Votes) EncodeScale ¶ added in v1.0.0
func (*Votes) MarshalLogObject ¶ added in v1.0.0
func (v *Votes) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
type VotingEligibility ¶ added in v1.0.0
type VotingEligibility struct { // the counter value used to generate this eligibility proof. if the value of J is 3, this is the smesher's // eligibility proof of the 3rd ballot/proposal in the epoch. J uint32 // the VRF signature of some epoch specific data and J. one can derive a Ballot's layerID from this signature. Sig []byte }
VotingEligibility includes the required values that, along with the smesher's VRF public key, allow non-interactive voting eligibility validation. this proof provides eligibility for both voting and making proposals.
func (*VotingEligibility) DecodeScale ¶ added in v1.0.0
func (t *VotingEligibility) DecodeScale(dec *scale.Decoder) (total int, err error)
func (*VotingEligibility) EncodeScale ¶ added in v1.0.0
func (t *VotingEligibility) EncodeScale(enc *scale.Encoder) (total int, err error)
func (*VotingEligibility) MarshalLogObject ¶ added in v1.0.0
func (v *VotingEligibility) MarshalLogObject(encoder log.ObjectEncoder) error
MarshalLogObject implements logging interface.
Source Files ¶
- account.go
- account_scale.go
- activation.go
- activation_scale.go
- activation_tx_header.go
- address.go
- atxid_list.go
- ballot.go
- ballot_scale.go
- beacon.go
- block.go
- block_scale.go
- bytes.go
- eligibility.go
- eligibility_scale.go
- encode.go
- hashes.go
- layer.go
- layer_scale.go
- malfeasance.go
- malfeasance_scale.go
- nipost.go
- nipost_scale.go
- nodeid.go
- proposal.go
- proposal_scale.go
- ratvar.go
- round.go
- testutil.go
- transaction.go
- transaction_header.go
- transaction_header_scale.go
- transaction_result.go
- transaction_result_scale.go
- transaction_scale.go
- verified_activation.go