Documentation ¶
Index ¶
- func BinaryInsert[T any](l *[]T, cmp func(entry T) int) (entry *T, added bool)
- func CalculateBudget(batch *light.DB, params *types.Parameters, epoch [2]uint64) (*big.Rat, error)
- func FindMajorBlock(c *light.Client, partition string, major uint64) (*protocol.IndexEntry, error)
- func GetDirectoryAnchor(batch *light.DB, blockIndex uint64) ([]byte, error)
- func GetRegisteredIdentity(c *light.Client, params *types.Parameters, idUrl *url.URL) (*types.Identity, *url.TxID, error)
- func GetTokenAccount(c *light.Client, u *url.URL) *protocol.TokenAccount
- func IsAccountLocked(params *types.Parameters, account *protocol.TokenAccount) bool
- func IsOwnedByStaking(params *types.Parameters, account *protocol.TokenAccount) bool
- func IsStakingRequest(params *types.Parameters, txn *protocol.Transaction) bool
- func LoadAllApproved(batch *light.DB, params *types.Parameters) ([]*types.Approved, error)
- func LoadAllRegistered(batch *light.DB, params *types.Parameters) ([]*types.Identity, error)
- func LoadRegisteredIdentity(batch *light.DB, params *types.Parameters, url *url.URL) (*types.Identity, error)
- func NewLogger() log.Logger
- func PullNetworkAccounts(ctx context.Context, c *light.Client) error
- func PullStaking(ctx context.Context, c *light.Client, params *types.Parameters) error
- func PullStakingForIdentities(ctx context.Context, c *light.Client, params *types.Parameters, ...) error
- func Remove[T any](l *[]T, cmp func(entry T) int) bool
- func RemoveAt[T any](l *[]T, i int)
- func ScanTransactions(batch *light.DB, url *url.URL, fn func(*TxExecuted) (stop bool, err error)) error
- func Search[T any](l []T, cmp func(entry T) int) (index int, found bool)
- type AccountStatus
- func GetAccountStatus(c *light.Client, identity *types.Identity, txid *url.TxID, account *url.URL) (*AccountStatus, error)
- func NewAccountStatus(c *light.Client, txid *url.TxID, account *types.Account) *AccountStatus
- func ScanRegistered(c *light.Client, params *types.Parameters) ([]*AccountStatus, error)
- type BlockInfo
- type BlockStream
- type BlockStreamOptions
- type RandHash
- func (n *RandHash) GetAElement(i int) (A [32]byte)
- func (n *RandHash) GetRandBuff(size int) (buff []byte)
- func (n *RandHash) GetRandInt64() int64
- func (n *RandHash) Next() []byte
- func (n *RandHash) NextA() (A [32]byte)
- func (n *RandHash) NextAList() (A [32]byte)
- func (n *RandHash) NextList() []byte
- func (n *RandHash) SetSeed(seed []byte)
- type SecurePrivateKey
- type StakingInfo
- type StakingService
- type TendermintZeroLogger
- type TxExecuted
- type TxWhen
- type Wallet
- type WalletOptions
- type WalletSigner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryInsert ¶
BinaryInsert uses Search to find the smallest index i in [0, len(l)) at which cmp(l[i]) ≥ 0. If i ≥ len(l), an empty entry is appended. Otherwise an empty entry is inserted at i unless cmp == 0. BinaryInsert returns l, the address of l[i], and whether a new entry was added.
func CalculateBudget ¶
CalculateBudget calculates the budget for a staking epoch.
func FindMajorBlock ¶
func GetDirectoryAnchor ¶
GetDirectoryAnchor returns the directory anchor at a given block index
func GetRegisteredIdentity ¶
func GetTokenAccount ¶
func IsAccountLocked ¶
func IsAccountLocked(params *types.Parameters, account *protocol.TokenAccount) bool
IsAccountLocked returns true if the account is unlocked, false otherwise
func IsOwnedByStaking ¶
func IsOwnedByStaking(params *types.Parameters, account *protocol.TokenAccount) bool
IsOwnedByStaking returns true if the account is governed by staking.acme/book and all other authorities are disabled.
func IsStakingRequest ¶
func IsStakingRequest(params *types.Parameters, txn *protocol.Transaction) bool
IsStakingRequest returns true if the transaction is an UpdateAccountAuth that transfers authority from the account to staking.acme/book
func LoadAllApproved ¶
func LoadAllRegistered ¶
LoadAllRegistered returns the list of registered staking accounts.
func LoadRegisteredIdentity ¶
func PullStaking ¶
PullStaking pulls all of the account data required by staking.
func PullStakingForIdentities ¶
func PullStakingForIdentities(ctx context.Context, c *light.Client, params *types.Parameters, identities ...*url.URL) error
PullStakingForIdentities pulls the account data required by staking, for specific identities.
func ScanTransactions ¶
func Search ¶
Search uses a binary search to find and return the smallest index i in [0, len(l)) at which cmp(l[i]) ≥ 0, assuming that on the range [0, len(l)), cmp(l[i]) ≥ 0 implies cmp(l[i+1]) ≥ 0. That is, Search requires that cmp ≥ 0 for some (possibly empty) prefix of the input range [0, len(l)) and then < 0 for the (possibly empty) remainder; Search returns the first ≥ 0 index and whether cmp == 0 for that index. If there is no such index, Search returns len(l), false.
Types ¶
type AccountStatus ¶
type AccountStatus struct { api.AccountStatus // contains filtered or unexported fields }
func GetAccountStatus ¶
func NewAccountStatus ¶
func ScanRegistered ¶
func ScanRegistered(c *light.Client, params *types.Parameters) ([]*AccountStatus, error)
func (*AccountStatus) Compare ¶
func (a *AccountStatus) Compare(b *AccountStatus) int
func (*AccountStatus) FindDepositsFor ¶
func (a *AccountStatus) FindDepositsFor(majorBlock, endMajorBlock uint64) error
func (*AccountStatus) FindLastChange ¶
func (a *AccountStatus) FindLastChange() error
func (*AccountStatus) GetStakeBalance ¶
func (a *AccountStatus) GetStakeBalance()
func (*AccountStatus) SetClient ¶
func (a *AccountStatus) SetClient(c *light.Client)
type BlockStream ¶
type BlockStream struct {
// contains filtered or unexported fields
}
func NewBlockStream ¶
func NewBlockStream(ctx context.Context, opts BlockStreamOptions) *BlockStream
NewBlockStream returns a new block stream starting from the specified height.
func (*BlockStream) Close ¶
func (s *BlockStream) Close()
Close closes the stream and cleans up allocated resources.
func (*BlockStream) Err ¶
func (s *BlockStream) Err() error
Err returns the error that occurred, or nil.
func (*BlockStream) Next ¶
func (s *BlockStream) Next(stop <-chan struct{}) (*BlockInfo, bool)
Next returns the next block. The stop channel has no effect while Next is processing past blocks. While Next is processing events: if stop is nil or open, Next will block; if stop is closed, Next will return immediately (nil, false) if there is no event ready.
type BlockStreamOptions ¶
type RandHash ¶
type RandHash struct { List [][]byte // contains filtered or unexported fields }
RandHash Creates a deterministic stream of hashes. We need this all over our tests and though this is late to the party, it is very useful in testing in SMT
func (*RandHash) GetAElement ¶
GetAElement Get an Array of an element out of the list of hashes
func (*RandHash) GetRandBuff ¶
GetRandBuff return a buffer of random data of the given size. Okay, we could do this much more efficiently, but meh!
func (*RandHash) GetRandInt64 ¶
GetRandInt64 Really returns a 63 bit number, as the return value is always positive.
type SecurePrivateKey ¶
func SecureSignerFromAddress ¶
func SecureSignerFromAddress(addr address.Address) (*SecurePrivateKey, error)
func (*SecurePrivateKey) Address ¶
func (k *SecurePrivateKey) Address() address.Address
type StakingInfo ¶
type StakingInfo struct { Identity *types.Identity Account *types.Account CurrentState *protocol.TokenAccount Transactions []*TxExecuted EffectiveType types.AccountType Balance *big.Int Deposits *big.Int Withdraws *big.Int WeightedBalance *big.Rat DelegatedBalance *big.Rat DelegatedType types.AccountType DelegatedPayout *url.URL }
StakingInfo records the status of a staking account at the end of a staking epoch.
func LoadStakingAccountHistory ¶
func LoadStakingAccountHistory(params *types.Parameters, batch *light.DB, identity *types.Identity, account *types.Account, majorBlock *[2]uint64) (*StakingInfo, error)
LoadStakingAccountHistory loads the history of a staking account for the given epoch.
func Staking ¶
func Staking(c *light.Client, params *types.Parameters, majorBlock [2]uint64, budget *big.Rat) ([]*StakingInfo, []*protocol.TokenRecipient, error)
Staking analyzes all staked accounts and determines the payout due to each for the given epoch. Staking returns the status of each staking account and a list of payouts.
- majorBlock specifies the start (inclusive) and end (exclusive) of the epoch.
- budget is the total payout budget.
- weights determines the weight for each staking account type, with a default weight of 1 (if a given type is not present in the map).
- delegationFee is the percentage of a delegator's payout that is transferred to their delegate.
type StakingService ¶
type StakingService struct { Client *light.Client Params *types.Parameters }
func (*StakingService) AccountStatus ¶
func (s *StakingService) AccountStatus(ctx context.Context, account *url.URL, _ api.AccountStatusOptions) (*api.AccountStatus, error)
type TendermintZeroLogger ¶
func (*TendermintZeroLogger) Debug ¶
func (l *TendermintZeroLogger) Debug(msg string, keyVals ...interface{})
func (*TendermintZeroLogger) Error ¶
func (l *TendermintZeroLogger) Error(msg string, keyVals ...interface{})
func (*TendermintZeroLogger) Info ¶
func (l *TendermintZeroLogger) Info(msg string, keyVals ...interface{})
func (*TendermintZeroLogger) With ¶
func (l *TendermintZeroLogger) With(keyVals ...interface{}) log.Logger
type TxExecuted ¶
type TxExecuted struct { api.TxWhen Transaction *protocol.Transaction }
TxExecuted is a transaction and information about when it was executed.
type WalletOptions ¶
type WalletSigner ¶
type WalletSigner struct { Key *address.PublicKey Wallet wallet.SigningService }
func (*WalletSigner) SetPublicKey ¶
func (s *WalletSigner) SetPublicKey(sig protocol.Signature) error