Documentation
¶
Index ¶
- func MulSaturate(a uint64, b uint64) uint64
- func OAdd(a uint64, b uint64) (res uint64, overflowed bool)
- func OAdd16(a uint16, b uint16) (res uint16, overflowed bool)
- func OMul(a uint64, b uint64) (res uint64, overflowed bool)
- func OSub(a uint64, b uint64) (res uint64, overflowed bool)
- func OneTimeIDForRound(round Round, keyDilution uint64) crypto.OneTimeSignatureIdentifier
- type AccountData
- func (u AccountData) IsZero() bool
- func (u AccountData) KeyDilution(proto config.ConsensusParams) uint64
- func (u AccountData) Money(proto config.ConsensusParams, rewardsLevel uint64) (money MicroAlgos, rewards MicroAlgos)
- func (u AccountData) VotingStake() MicroAlgos
- func (u AccountData) WithUpdatedRewards(proto config.ConsensusParams, rewardsLevel uint64) AccountData
- type AccountDetail
- type Address
- type AssetHolding
- type AssetIndex
- type AssetLocator
- type AssetParams
- type BalanceDetail
- type BalanceRecord
- type MicroAlgos
- func (a *MicroAlgos) CodecDecodeSelf(dec *codec.Decoder)
- func (a MicroAlgos) CodecEncodeSelf(enc *codec.Encoder)
- func (a MicroAlgos) GreaterThan(b MicroAlgos) bool
- func (a MicroAlgos) IsZero() bool
- func (a MicroAlgos) LessThan(b MicroAlgos) bool
- func (a MicroAlgos) RewardUnits(proto config.ConsensusParams) uint64
- func (a MicroAlgos) ToUint64() uint64
- type OverflowTracker
- func (t *OverflowTracker) Add(a uint64, b uint64) uint64
- func (t *OverflowTracker) Add16(a uint16, b uint16) uint16
- func (t *OverflowTracker) AddA(a MicroAlgos, b MicroAlgos) MicroAlgos
- func (t *OverflowTracker) AddR(a Round, b Round) Round
- func (t *OverflowTracker) Mul(a uint64, b uint64) uint64
- func (t *OverflowTracker) ScalarMulA(a MicroAlgos, b uint64) MicroAlgos
- func (t *OverflowTracker) Sub(a uint64, b uint64) uint64
- func (t *OverflowTracker) SubA(a MicroAlgos, b MicroAlgos) MicroAlgos
- func (t *OverflowTracker) SubR(a Round, b Round) Round
- type Round
- type RoundInterval
- type Status
- type SupplyDetail
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MulSaturate ¶
MulSaturate multiplies 2 values with saturation on overflow
func OneTimeIDForRound ¶
func OneTimeIDForRound(round Round, keyDilution uint64) crypto.OneTimeSignatureIdentifier
OneTimeIDForRound maps a round to the identifier for which ephemeral key should be used for that round. keyDilution specifies the number of keys in the bottom-level of the two-level key structure.
Types ¶
type AccountData ¶
type AccountData struct { Status Status `codec:"onl"` MicroAlgos MicroAlgos `codec:"algo"` // RewardsBase is used to implement rewards. // This is not meaningful for accounts with Status=NotParticipating. // // Every block assigns some amount of rewards (algos) to every // participating account. The amount is the product of how much // block.RewardsLevel increased from the previous block and // how many whole config.Protocol.RewardUnit algos this // account holds. // // For performance reasons, we do not want to walk over every // account to apply these rewards to AccountData.MicroAlgos. Instead, // we defer applying the rewards until some other transaction // touches that participating account, and at that point, apply all // of the rewards to the account's AccountData.MicroAlgos. // // For correctness, we need to be able to determine how many // total algos are present in the system, including deferred // rewards (deferred in the sense that they have not been // reflected in the account's AccountData.MicroAlgos, as described // above). To compute this total efficiently, we avoid // compounding rewards (i.e., no rewards on rewards) until // they are applied to AccountData.MicroAlgos. // // Mechanically, RewardsBase stores the block.RewardsLevel // whose rewards are already reflected in AccountData.MicroAlgos. // If the account is Status=Offline or Status=Online, its // effective balance (if a transaction were to be issued // against this account) may be higher, as computed by // AccountData.Money(). That function calls // AccountData.WithUpdatedRewards() to apply the deferred // rewards to AccountData.MicroAlgos. RewardsBase uint64 `codec:"ebase"` // RewardedMicroAlgos is used to track how many algos were given // to this account since the account was first created. // // This field is updated along with RewardBase; note that // it won't answer the question "how many algos did I make in // the past week". RewardedMicroAlgos MicroAlgos `codec:"ern"` VoteID crypto.OneTimeSignatureVerifier `codec:"vote"` SelectionID crypto.VRFVerifier `codec:"sel"` VoteFirstValid Round `codec:"voteFst"` VoteLastValid Round `codec:"voteLst"` VoteKeyDilution uint64 `codec:"voteKD"` // If this account created an asset, AssetParams stores // the parameters defining that asset. The params are indexed // by the Index of the AssetID; the Creator is this account's address. // // An account with any asset in AssetParams cannot be // closed, until the asset is destroyed. An asset can // be destroyed if this account holds AssetParams.Total units // of that asset (in the Assets array below). // // NOTE: do not modify this value in-place in existing AccountData // structs; allocate a copy and modify that instead. AccountData // is expected to have copy-by-value semantics. AssetParams map[AssetIndex]AssetParams `codec:"apar"` // Assets is the set of assets that can be held by this // account. Assets (i.e., slots in this map) are explicitly // added and removed from an account by special transactions. // The map is keyed by the AssetID, which is the address of // the account that created the asset plus a unique counter // to distinguish re-created assets. // // Each asset bumps the required MinBalance in this account. // // An account that creates an asset must have its own asset // in the Assets map until that asset is destroyed. // // NOTE: do not modify this value in-place in existing AccountData // structs; allocate a copy and modify that instead. AccountData // is expected to have copy-by-value semantics. Assets map[AssetIndex]AssetHolding `codec:"asset"` // contains filtered or unexported fields }
AccountData contains the data associated with a given address.
This includes the account balance, delegation keys, delegation status, and a custom note.
func MakeAccountData ¶
func MakeAccountData(status Status, algos MicroAlgos) AccountData
MakeAccountData returns a UserToken
func (AccountData) IsZero ¶
func (u AccountData) IsZero() bool
IsZero checks if an AccountData value is the same as its zero value.
func (AccountData) KeyDilution ¶
func (u AccountData) KeyDilution(proto config.ConsensusParams) uint64
KeyDilution returns the key dilution for this account, returning the default key dilution if not explicitly specified.
func (AccountData) Money ¶
func (u AccountData) Money(proto config.ConsensusParams, rewardsLevel uint64) (money MicroAlgos, rewards MicroAlgos)
Money returns the amount of MicroAlgos associated with the user's account
func (AccountData) VotingStake ¶
func (u AccountData) VotingStake() MicroAlgos
VotingStake returns the amount of MicroAlgos associated with the user's account for the purpose of participating in the Algorand protocol. It assumes the caller has already updated rewards appropriately using WithUpdatedRewards().
func (AccountData) WithUpdatedRewards ¶
func (u AccountData) WithUpdatedRewards(proto config.ConsensusParams, rewardsLevel uint64) AccountData
WithUpdatedRewards returns an updated number of algos in an AccountData to reflect rewards up to some rewards level.
type AccountDetail ¶
type AccountDetail struct { Address Address Algos MicroAlgos Status Status }
AccountDetail encapsulates meaningful details about a given account, for external consumption
type Address ¶
Address is a unique identifier corresponding to ownership of money
func UnmarshalChecksumAddress ¶
UnmarshalChecksumAddress tries to unmarshal the checksummed address string.
func (Address) GetChecksum ¶
GetChecksum returns the checksum as []byte Checksum in Algorand are the last 4 bytes of the shortAddress Hash. H(Address)[28:]
func (Address) GetUserAddress ¶
GetUserAddress returns the human-readable, checksummed version of the address
func (Address) MarshalText ¶
MarshalText returns the address string as an array of bytes
func (*Address) UnmarshalText ¶
UnmarshalText initializes the Address from an array of bytes.
type AssetHolding ¶
AssetHolding describes an asset held by an account.
type AssetIndex ¶
type AssetIndex uint64
AssetIndex is the unique integer index of an asset that can be used to look up the creator of the asset, whose balance record contains the AssetParams
type AssetLocator ¶
type AssetLocator struct { Creator Address Index AssetIndex }
AssetLocator stores both the asset creator, whose balance record contains the asset parameters, and the asset index, which is the key into those parameters
type AssetParams ¶
type AssetParams struct { // Total specifies the total number of units of this asset // created. Total uint64 `codec:"t"` // DefaultFrozen specifies whether slots for this asset // in user accounts are frozen by default or not. DefaultFrozen bool `codec:"df"` // UnitName specifies a hint for the name of a unit of // this asset. UnitName string `codec:"un"` // AssetName specifies a hint for the name of the asset. AssetName string `codec:"an"` // URL specifies a URL where more information about the asset can be // retrieved URL string `codec:"au"` // MetadataHash specifies a commitment to some unspecified asset // metadata. The format of this metadata is up to the application. MetadataHash [32]byte `codec:"am"` // Manager specifies an account that is allowed to change the // non-zero addresses in this AssetParams. Manager Address `codec:"m"` // Reserve specifies an account whose holdings of this asset // should be reported as "not minted". Reserve Address `codec:"r"` // Freeze specifies an account that is allowed to change the // frozen state of holdings of this asset. Freeze Address `codec:"f"` // Clawback specifies an account that is allowed to take units // of this asset from any account. Clawback Address `codec:"c"` // contains filtered or unexported fields }
AssetParams describes the parameters of an asset.
type BalanceDetail ¶
type BalanceDetail struct { Round Round TotalMoney MicroAlgos OnlineMoney MicroAlgos Accounts []AccountDetail }
BalanceDetail encapsulates meaningful details about the current balances of the ledger, for external consumption
type BalanceRecord ¶
type BalanceRecord struct { Addr Address `codec:"addr"` AccountData // contains filtered or unexported fields }
BalanceRecord pairs an account's address with its associated data.
func (BalanceRecord) ToBeHashed ¶
func (u BalanceRecord) ToBeHashed() (protocol.HashID, []byte)
ToBeHashed implements the crypto.Hashable interface
type MicroAlgos ¶
type MicroAlgos struct {
Raw uint64
}
MicroAlgos is our unit of currency. It is wrapped in a struct to nudge developers to use an overflow-checking library for any arithmetic.
func MulAIntSaturate ¶
func MulAIntSaturate(a MicroAlgos, b int) MicroAlgos
MulAIntSaturate uses MulSaturate to multiply b (int) with a (MicroAlgos)
func OAddA ¶
func OAddA(a MicroAlgos, b MicroAlgos) (res MicroAlgos, overflowed bool)
OAddA adds 2 MicroAlgos values with overflow tracking
func OSubA ¶
func OSubA(a MicroAlgos, b MicroAlgos) (res MicroAlgos, overflowed bool)
OSubA subtracts b from a with overflow tracking
func (*MicroAlgos) CodecDecodeSelf ¶
func (a *MicroAlgos) CodecDecodeSelf(dec *codec.Decoder)
CodecDecodeSelf implements codec.Selfer to decode MicroAlgos as a simple int
func (MicroAlgos) CodecEncodeSelf ¶
func (a MicroAlgos) CodecEncodeSelf(enc *codec.Encoder)
CodecEncodeSelf implements codec.Selfer to encode MicroAlgos as a simple int
func (MicroAlgos) GreaterThan ¶
func (a MicroAlgos) GreaterThan(b MicroAlgos) bool
GreaterThan implements arithmetic comparison for MicroAlgos
func (MicroAlgos) IsZero ¶
func (a MicroAlgos) IsZero() bool
IsZero implements arithmetic comparison for MicroAlgos
func (MicroAlgos) LessThan ¶
func (a MicroAlgos) LessThan(b MicroAlgos) bool
LessThan implements arithmetic comparison for MicroAlgos
func (MicroAlgos) RewardUnits ¶
func (a MicroAlgos) RewardUnits(proto config.ConsensusParams) uint64
RewardUnits returns the number of reward units in some number of algos
func (MicroAlgos) ToUint64 ¶
func (a MicroAlgos) ToUint64() uint64
ToUint64 converts the amount of algos to uint64
type OverflowTracker ¶
type OverflowTracker struct {
Overflowed bool
}
OverflowTracker is used to track when an operation causes an overflow
func (*OverflowTracker) Add ¶
func (t *OverflowTracker) Add(a uint64, b uint64) uint64
Add adds 2 values with overflow detection
func (*OverflowTracker) Add16 ¶
func (t *OverflowTracker) Add16(a uint16, b uint16) uint16
Add16 adds 2 uint16 values with overflow detection
func (*OverflowTracker) AddA ¶
func (t *OverflowTracker) AddA(a MicroAlgos, b MicroAlgos) MicroAlgos
AddA adds 2 MicroAlgos values with overflow tracking
func (*OverflowTracker) AddR ¶
func (t *OverflowTracker) AddR(a Round, b Round) Round
AddR adds 2 Round values with overflow tracking
func (*OverflowTracker) Mul ¶
func (t *OverflowTracker) Mul(a uint64, b uint64) uint64
Mul multiplies b from a with overflow detection
func (*OverflowTracker) ScalarMulA ¶
func (t *OverflowTracker) ScalarMulA(a MicroAlgos, b uint64) MicroAlgos
ScalarMulA multiplies an Algo amount by a scalar
func (*OverflowTracker) Sub ¶
func (t *OverflowTracker) Sub(a uint64, b uint64) uint64
Sub subtracts b from a with overflow detection
func (*OverflowTracker) SubA ¶
func (t *OverflowTracker) SubA(a MicroAlgos, b MicroAlgos) MicroAlgos
SubA subtracts b from a with overflow tracking
type Round ¶
type Round uint64
Round represents a protocol round index
func (Round) SubSaturate ¶
SubSaturate subtracts two rounds with saturation arithmetic that does not wrap around past zero, and instead returns 0 on underflow.
type Status ¶
type Status byte
Status is the delegation status of an account's MicroAlgos
const ( // Offline indicates that the associated account is delegated. Offline Status = iota // Online indicates that the associated account used as part of the delegation pool. Online // NotParticipating indicates that the associated account is neither a delegator nor a delegate. Currently it is reserved for the incentive pool. NotParticipating )
type SupplyDetail ¶
type SupplyDetail struct { Round Round TotalMoney MicroAlgos OnlineMoney MicroAlgos }
SupplyDetail encapsulates meaningful details about the ledger's current token supply