Documentation ¶
Overview ¶
Package types defines the types used by go-spacemesh consensus algorithms and structs
Index ¶
- Constants
- Variables
- func ATXIdsToBytes(ids []ATXID) ([]byte, error)
- func BlockIdsField(ids []BlockID) log.Field
- func BlockIdsToBytes(ids []BlockID) ([]byte, error)
- func IsProcessingError(err error) bool
- func NIPostChallengeToBytes(challenge *NIPostChallenge) ([]byte, error)
- func SetLayersPerEpoch(layers uint32)
- func Shorten(s string, maxlen int) string
- func TxIdsField(ids []TransactionID) log.Field
- type ATXID
- type ATXIDList
- type AccountState
- type ActivationTx
- type ActivationTxHeader
- type Address
- func (a Address) Big() *big.Int
- func (a Address) Bytes() []byte
- func (a Address) Field() log.Field
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hash() Hash32
- func (a Address) Hex() string
- func (a *Address) SetBytes(b []byte)
- func (a Address) Short() string
- func (a Address) String() string
- type Block
- type BlockEligibilityProof
- type BlockHeader
- type BlockID
- type DBBlock
- type DoubleCache
- type EpochID
- type Hash12
- type Hash20
- func (h Hash20) Big() *big.Int
- func (h Hash20) Bytes() []byte
- 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 BytesToHash(b []byte) Hash32
- func CalcATXHash32(atx *ActivationTx) Hash32
- func CalcAggregateHash32(h Hash32, data []byte) Hash32
- func CalcBlockHash32Presorted(sortedView []BlockID, additionalBytes []byte) Hash32
- func CalcBlocksHash32(view []BlockID, additionalBytes []byte) Hash32
- func CalcHash32(data []byte) Hash32
- func HexToHash32(s string) Hash32
- func (h Hash32) Bytes() []byte
- func (h Hash32) Field() log.Field
- func (h Hash32) Format(s fmt.State, c rune)
- func (h Hash32) Generate(rand *rand.Rand, _ int) reflect.Value
- func (h Hash32) Hex() string
- func (h Hash32) MarshalText() ([]byte, error)
- func (h *Hash32) Scan(src interface{}) 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 InnerTransaction
- type Layer
- 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 (l LayerID) Difference(other LayerID) uint32
- 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 MeshTransaction
- type MiniBlock
- type MultipleAccountsState
- type NIPost
- type NIPostChallenge
- type NodeID
- type PoetProof
- type PoetProofMessage
- type PoetRound
- type Post
- type PostMetadata
- type ProcessingError
- type RatVar
- type Reward
- type RoundID
- type StorageSize
- type Transaction
- type TransactionID
- type TryMutex
Constants ¶
const ( // LayerIDSize in bytes. LayerIDSize = 4 // BlockIDSize in bytes. // FIXME(dshulyak) why do we cast to hash32 when returning bytes? BlockIDSize = Hash32Length )
const (
// AddressLength is the expected length of the address
AddressLength = 20
)
const (
// Hash32Length is 32, the expected length of the hash
Hash32Length = 32
)
Variables ¶
var ( Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big0 = big.NewInt(0) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) )
Common big integers often used
var ( // InterfaceToBytes is an alias to codec.Encode. InterfaceToBytes = codec.Encode // BytesToInterface is an alias to codec.Decode. BytesToInterface = codec.Decode )
var EmptyATXID = &ATXID{}
EmptyATXID is a canonical empty ATXID.
var EmptyTransactionID = TransactionID{}
EmptyTransactionID is a canonical empty TransactionID.
Functions ¶
func ATXIdsToBytes ¶ added in v0.1.15
ATXIdsToBytes serializes a slice of atx ids.
func BlockIdsField ¶ added in v1.0.0
BlockIdsField returns a list of loggable fields for a given list of BlockIDs
func BlockIdsToBytes ¶ added in v0.1.15
BlockIdsToBytes serializes a slice of BlockIDs.
func IsProcessingError ¶
IsProcessingError returns true if the given error is a processing error.
func NIPostChallengeToBytes ¶
func NIPostChallengeToBytes(challenge *NIPostChallenge) ([]byte, error)
NIPostChallengeToBytes serializes a NIPostChallenge.
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 SortAtxIDs ¶ added in v0.1.15
SortAtxIDs sorts a list of atx IDs in lexicographic order, in-place.
func (ATXID) Compare ¶ added in v0.1.15
Compare returns true if other (the given ATXID) is less than this ATXID, by lexicographic comparison.
func (ATXID) Field ¶ added in v0.1.11
Field returns a log field. Implements the LoggableField interface.
func (ATXID) ShortString ¶ added in v0.1.11
ShortString returns the first few characters of the ID, for logging purposes.
type AccountState ¶ added in v0.1.16
AccountState struct represents basic account data: nonce and balance Todo: get rid of big.Int everywhere and replace with uint64 See https://github.com/spacemeshos/go-spacemesh/issues/2192
type ActivationTx ¶
type ActivationTx struct { *InnerActivationTx Sig []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, coinbase Address, nipost *NIPost, numUnits uint, initialPost *Post) *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()
CalcAndSetID calculates and sets the cached ID field. This field must be set before calling the ID() method.
func (*ActivationTx) Fields ¶ added in v0.1.15
func (atx *ActivationTx) Fields(size int) []log.LoggableField
Fields returns an array of LoggableFields for logging
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) InnerBytes ¶ added in v0.1.11
func (atx *ActivationTx) InnerBytes() ([]byte, error)
InnerBytes returns a byte slice of the serialization of the inner ATX (excluding the signature field).
type ActivationTxHeader ¶
type ActivationTxHeader struct { NIPostChallenge Coinbase Address NumUnits uint // contains filtered or unexported fields }
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 returns the ATX's weight = numUnits * ticks.
func (*ActivationTxHeader) Hash32 ¶
func (atxh *ActivationTxHeader) Hash32() Hash32
Hash32 returns the ATX's ID as a Hash32.
func (*ActivationTxHeader) ID ¶ added in v0.1.11
func (atxh *ActivationTxHeader) ID() ATXID
ID returns the ATX's ID.
func (*ActivationTxHeader) SetID ¶ added in v0.1.11
func (atxh *ActivationTxHeader) SetID(id *ATXID)
SetID sets the ATXID in this ATX's cache.
func (*ActivationTxHeader) ShortString ¶
func (atxh *ActivationTxHeader) ShortString() string
ShortString returns the first 5 characters of the ID, for logging purposes.
func (*ActivationTxHeader) TargetEpoch ¶
func (atxh *ActivationTxHeader) TargetEpoch() EpochID
TargetEpoch returns the target epoch of the activation transaction. This is the epoch in which the miner is eligible to participate thanks to the ATX.
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an spacemesh account.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func StringToAddress ¶
StringToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left. It is identical to HexToAddress, except decoding errors are returned instead of swallowed.
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) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
type Block ¶
Block includes all of a block's fields, including signature and a cache of the BlockID and MinerID.
func NewExistingBlock ¶
func NewExistingBlock(layerIndex LayerID, data []byte, txs []TransactionID) *Block
NewExistingBlock returns a block in the given layer with the given arbitrary data. The block is signed with a random keypair that isn't stored anywhere. This method should be phased out of use in production code (it's currently used in tests and the temporary genesis flow).
func SortBlocks ¶
SortBlocks sorts a list of Blocks in lexicographic order of their IDs, in-place.
func (*Block) Fields ¶ added in v0.1.15
func (b *Block) Fields() []log.LoggableField
Fields returns an array of LoggableFields for logging
func (Block) Hash32 ¶
Hash32 returns a Hash32 whose first 20 bytes are the bytes of this BlockID, it is right-padded with zeros. This implements the sync.item interface.
func (*Block) Initialize ¶ added in v0.1.2
func (b *Block) Initialize()
Initialize calculates and sets the block's cached ID and MinerID. This should be called once all the other fields of the block are set.
func (Block) ShortString ¶
ShortString returns a the first 5 characters of the ID, for logging purposes.
type BlockEligibilityProof ¶
type BlockEligibilityProof struct { // J is the counter value used to generate this eligibility proof. Each value of J must only be used once. J uint32 // Sig is the VRF signature from which the block's LayerID is derived. Sig []byte }
BlockEligibilityProof includes the required values that, along with the miner's VRF public key, allow non-interactive block eligibility validation.
type BlockHeader ¶
type BlockHeader struct { LayerIndex LayerID ATXID ATXID EligibilityProof BlockEligibilityProof Data []byte BaseBlock BlockID AgainstDiff []BlockID // base block explicitly supports a block that we want to vote against ForDiff []BlockID // any additional blocks we want to support that base block doesn't (incl. in newer layers) NeutralDiff []BlockID // blocks that the base block is explicitly for or against for which we are neutral. }
BlockHeader includes all of a block's fields, except the list of transaction IDs, activation transaction IDs and the signature. TODO: consider combining this with MiniBlock, since this type isn't used independently anywhere.
type BlockID ¶
type BlockID Hash20
BlockID is a 20-byte sha256 sum of the serialized block, used to identify it.
func BlockIDs ¶ added in v0.1.11
BlockIDs returns a slice of BlockIDs corresponding to the given blocks.
func BytesToBlockIds ¶
BytesToBlockIds deserializes a slice of BlockIDs.
func SortBlockIDs ¶ added in v0.1.11
SortBlockIDs sorts a list of BlockIDs in lexicographic order, in-place.
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.
type DBBlock ¶
type DBBlock struct { MiniBlock // NOTE(dshulyak) this is a bit redundant to store ID here as well but less likely // to break if in future key for database will be changed ID BlockID Signature []byte MinerID []byte // derived from signature when block is received }
DBBlock is a Block structure as it is stored in DB.
type DoubleCache ¶
type DoubleCache struct {
// contains filtered or unexported fields
}
DoubleCache is a structure for storing which keys have been encountered before. It's initialized with a size and it stores between size and 2*size keys. Every time the cache size reaches 2*size and a new value is added, the oldest size keys are discarded and the size drops back to size. DoubleCache is thread safe.
func NewDoubleCache ¶
func NewDoubleCache(size uint) *DoubleCache
NewDoubleCache returns a new DoubleCache.
func (*DoubleCache) GetOrInsert ¶
func (a *DoubleCache) GetOrInsert(key Hash12) bool
GetOrInsert checks if a value is already in the cache, otherwise it adds it. Returns bool whether or not the value was found in the cache (true - already in cache, false - wasn't in cache before this was called).
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.
func (EpochID) NeedsGoldenPositioningATX ¶ added in v0.1.28
NeedsGoldenPositioningATX returns true if ATXs in this epoch require positioning ATX to be equal to the Golden ATX. All ATXs in epoch 1 must have the Golden ATX as positioning ATX.
type Hash12 ¶
type Hash12 [hash12Length]byte
Hash12 represents the first 12 bytes of sha256, mostly used for internal caches
func CalcHash12 ¶
CalcHash12 returns the 12-byte prefix of the sha256 sum of the given byte slice.
func CalcMessageHash12 ¶
CalcMessageHash12 returns the 12-byte sha256 sum of the given msg suffixed with protocol.
type Hash20 ¶
type Hash20 [hash20Length]byte
Hash20 represents the 20-byte sha256 hash of arbitrary data.
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 sha256 hash of arbitrary data.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func CalcATXHash32 ¶ added in v0.1.11
func CalcATXHash32(atx *ActivationTx) Hash32
CalcATXHash32 returns the 32-byte sha256 sum of serialization of the given ATX.
func CalcAggregateHash32 ¶ added in v0.1.16
CalcAggregateHash32 returns the 32-byte sha256 sum of the given data aggregated with previous hash h
func CalcBlockHash32Presorted ¶
CalcBlockHash32Presorted returns the 32-byte sha256 sum of the block IDs, in the order given. The pre-image is prefixed with additionalBytes.
func CalcBlocksHash32 ¶
CalcBlocksHash32 returns the 32-byte sha256 sum of the block IDs, sorted in lexicographic order. The pre-image is prefixed with additionalBytes.
func CalcHash32 ¶
CalcHash32 returns the 32-byte sha256 sum of the given data.
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 (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 { *ActivationTxHeader NIPost *NIPost InitialPost *Post }
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.
type InnerTransaction ¶
type InnerTransaction struct { AccountNonce uint64 Recipient Address GasLimit uint64 Fee uint64 Amount uint64 }
InnerTransaction includes all of a transaction's fields, except the signature (origin and id aren't stored).
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer contains a list of blocks and their corresponding LayerID.
func NewExistingLayer ¶
NewExistingLayer returns a new layer with the given list of blocks without validation.
func (*Layer) AddBlock ¶
AddBlock adds a block to this layer. Panics if the block's index doesn't match the layer.
func (*Layer) BlocksIDs ¶ added in v1.0.0
BlocksIDs returns the list of IDs of blocks in this layer.
func (*Layer) Field ¶ added in v0.1.15
Field returns a log field. Implements the LoggableField interface.
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 blocks 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) Difference ¶ added in v1.0.0
Difference returns the difference between current and other layer.
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 MeshTransaction ¶ added in v1.0.0
type MeshTransaction struct { Transaction LayerID LayerID BlockID BlockID }
MeshTransaction is stored in the mesh and included in the block.
type MiniBlock ¶
type MiniBlock struct { BlockHeader TxIDs []TransactionID ActiveSet *[]ATXID RefBlock *BlockID }
MiniBlock includes all of a block's fields, except for the signature. This structure is serialized and signed to produce the block signature.
type MultipleAccountsState ¶ added in v0.1.16
type MultipleAccountsState struct { Root string `json:"root"` Accounts map[string]AccountState `json:"accounts"` // key is in hex string format e.g. 0x12... }
MultipleAccountsState is a struct used to dump an entire state root
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.
type NIPostChallenge ¶ added in v1.0.0
type NIPostChallenge struct { NodeID NodeID Sequence uint64 PrevATXID ATXID PubLayerID LayerID StartTick uint64 EndTick uint64 PositioningATX 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 the node ID, 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) Hash ¶ added in v1.0.0
func (challenge *NIPostChallenge) Hash() (*Hash32, error)
Hash serializes the NIPostChallenge and returns its hash.
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.
type NodeID ¶ added in v0.1.11
type NodeID struct { // Key is the miner's Edwards public key Key string // VRFPublicKey is the miner's public key used for VRF. VRFPublicKey []byte }
NodeID contains a miner's two public keys.
func BytesToNodeID ¶ added in v0.1.28
BytesToNodeID deserializes a byte slice into a NodeID TODO: length of the input will be made exact when the NodeID is compressed into one single key (https://github.com/spacemeshos/go-spacemesh/issues/2269)
func StringToNodeID ¶ added in v0.1.28
StringToNodeID deserializes a string into a NodeID TODO: length of the input will be made exact when the NodeID is compressed into one single key (https://github.com/spacemeshos/go-spacemesh/issues/2269)
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 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.
type PoetProofMessage ¶
PoetProofMessage is the envelope which includes the PoetProof, service ID, round ID and signature.
func (PoetProofMessage) Ref ¶
func (proofMessage PoetProofMessage) Ref() ([]byte, error)
Ref returns the reference to the PoET proof message. It's the sha256 sum of the entire proof message.
type PostMetadata ¶ added in v1.0.0
PostMetadata is similar postShared.ProofMetadata, but without the fields which can be derived elsewhere in a given ATX (ID, NumUnits).
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 RatVar ¶ added in v1.0.0
RatVar is a wrapper for big.Rat to use it with the pflag package.
type Reward ¶
type Reward struct { Layer LayerID TotalReward uint64 LayerRewardEstimate uint64 SmesherID NodeID Coinbase Address }
Reward is a virtual reward transaction, which the node keeps track of for the gRPC api.
type RoundID ¶ added in v1.0.0
type RoundID uint32
RoundID is the round ID. It's 1-based, so the first round equals to 1.
type StorageSize ¶
type StorageSize float64
StorageSize is a wrapper around a float value that supports user friendly formatting.
func (StorageSize) String ¶
func (s StorageSize) String() string
String implements the stringer interface.
func (StorageSize) TerminalString ¶
func (s StorageSize) TerminalString() string
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
type Transaction ¶
type Transaction struct { InnerTransaction Signature [64]byte // contains filtered or unexported fields }
Transaction contains all transaction fields, including the signature and cached origin address and transaction ID.
func BytesToTransaction ¶ added in v0.1.15
func BytesToTransaction(buf []byte) (*Transaction, error)
BytesToTransaction deserializes a Transaction.
func NewSignedTx ¶ added in v0.1.15
func NewSignedTx(nonce uint64, rec Address, amount, gas, fee uint64, signer *signing.EdSigner) (*Transaction, error)
NewSignedTx is used in TESTS ONLY to generate signed txs
func (*Transaction) CalcAndSetOrigin ¶
func (t *Transaction) CalcAndSetOrigin() error
CalcAndSetOrigin extracts the public key from the transaction's signature and caches it as the transaction's origin address.
func (*Transaction) Hash32 ¶
func (t *Transaction) Hash32() Hash32
Hash32 returns the TransactionID as a Hash32.
func (*Transaction) ID ¶ added in v0.1.11
func (t *Transaction) ID() TransactionID
ID returns the transaction's ID. If it's not cached, it's calculated, cached and returned.
func (*Transaction) Origin ¶
func (t *Transaction) Origin() Address
Origin returns the transaction's origin address: the public key extracted from the transaction signature.
func (*Transaction) SetOrigin ¶
func (t *Transaction) SetOrigin(origin Address)
SetOrigin sets the cache of the transaction's origin address.
func (*Transaction) ShortString ¶
func (t *Transaction) ShortString() string
ShortString returns a the first 5 characters of the ID, for logging purposes.
func (*Transaction) String ¶
func (t *Transaction) String() string
String returns a string representation of the Transaction, for logging purposes. It implements the fmt.Stringer interface.
type TransactionID ¶ added in v0.1.11
type TransactionID Hash32
TransactionID is a 32-byte sha256 sum of the transaction, used as an identifier.
func (TransactionID) Bytes ¶ added in v0.1.11
func (id TransactionID) Bytes() []byte
Bytes returns the TransactionID as a byte slice.
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.