internal

package
v0.0.0-...-00d0827 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryInsert

func BinaryInsert[T any](l *[]T, cmp func(entry T) int) (entry *T, added bool)

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

func CalculateBudget(batch *light.DB, params *types.Parameters, epoch [2]uint64) (*big.Rat, error)

CalculateBudget calculates the budget for a staking epoch.

func FindMajorBlock

func FindMajorBlock(c *light.Client, partition string, major uint64) (*protocol.IndexEntry, error)

func GetDirectoryAnchor

func GetDirectoryAnchor(batch *light.DB, blockIndex uint64) ([]byte, error)

GetDirectoryAnchor returns the directory anchor at a given block index

func GetRegisteredIdentity

func GetRegisteredIdentity(c *light.Client, params *types.Parameters, idUrl *url.URL) (*types.Identity, *url.TxID, error)

func GetTokenAccount

func GetTokenAccount(c *light.Client, u *url.URL) *protocol.TokenAccount

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 LoadAllApproved(batch *light.DB, params *types.Parameters) ([]*types.Approved, error)

func LoadAllRegistered

func LoadAllRegistered(batch *light.DB, params *types.Parameters) ([]*types.Identity, error)

LoadAllRegistered returns the list of registered staking accounts.

func LoadRegisteredIdentity

func LoadRegisteredIdentity(batch *light.DB, params *types.Parameters, url *url.URL) (*types.Identity, error)

func NewLogger

func NewLogger() log.Logger

func PullNetworkAccounts

func PullNetworkAccounts(ctx context.Context, c *light.Client) error

func PullStaking

func PullStaking(ctx context.Context, c *light.Client, params *types.Parameters) error

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 Remove

func Remove[T any](l *[]T, cmp func(entry T) int) bool

Remove removes the specified element.

func RemoveAt

func RemoveAt[T any](l *[]T, i int)

RemoveAt removes the specified element.

func ScanTransactions

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)

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 GetAccountStatus(c *light.Client, identity *types.Identity, txid *url.TxID, account *url.URL) (*AccountStatus, error)

func NewAccountStatus

func NewAccountStatus(c *light.Client, txid *url.TxID, account *types.Account) *AccountStatus

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 BlockInfo

type BlockInfo struct {
	Index uint64
	Time  time.Time
	Major *uint64
}

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 BlockStreamOptions struct {
	Light   *light.Client
	Querier api.Querier
	Events  api.EventService
	Start   uint64
}

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

func (n *RandHash) GetAElement(i int) (A [32]byte)

GetAElement Get an Array of an element out of the list of hashes

func (*RandHash) GetRandBuff

func (n *RandHash) GetRandBuff(size int) (buff []byte)

GetRandBuff return a buffer of random data of the given size. Okay, we could do this much more efficiently, but meh!

func (*RandHash) GetRandInt64

func (n *RandHash) GetRandInt64() int64

GetRandInt64 Really returns a 63 bit number, as the return value is always positive.

func (*RandHash) Next

func (n *RandHash) Next() []byte

Next Returns the next hash in a deterministic sequence of hashes

func (*RandHash) NextA

func (n *RandHash) NextA() (A [32]byte)

NextA Returns the next hash array in a deterministic sequence of hashes

func (*RandHash) NextAList

func (n *RandHash) NextAList() (A [32]byte)

NextAList Just like NextA, but each ash is logged in RandHash.ListA

func (*RandHash) NextList

func (n *RandHash) NextList() []byte

NextList Just like Next, but each hash is logged in RandHash.List

func (*RandHash) SetSeed

func (n *RandHash) SetSeed(seed []byte)

SetSeed If the tester wishes a different sequence of hashes, a seed can be specified

type SecurePrivateKey

type SecurePrivateKey struct {
	Pub  *address.PublicKey
	Priv *memguard.Enclave
}

func SecureSignerFromAddress

func SecureSignerFromAddress(addr address.Address) (*SecurePrivateKey, error)

func (*SecurePrivateKey) Address

func (k *SecurePrivateKey) Address() address.Address

func (*SecurePrivateKey) Sign

func (k *SecurePrivateKey) Sign(message []byte) ([]byte, error)

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

type TendermintZeroLogger struct {
	Zerolog zerolog.Logger
	Trace   bool
}

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 TxWhen

type TxWhen = api.TxWhen

type Wallet

type Wallet struct {
	*jsonrpc.Client
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(opts WalletOptions) (w *Wallet, err error)

type WalletOptions

type WalletOptions struct {
	Address string
	Path    string
	Vault   string
}

type WalletSigner

type WalletSigner struct {
	Key    *address.PublicKey
	Wallet wallet.SigningService
}

func (*WalletSigner) SetPublicKey

func (s *WalletSigner) SetPublicKey(sig protocol.Signature) error

func (*WalletSigner) Sign

func (s *WalletSigner) Sign(sig protocol.Signature, _, message []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL