Documentation
¶
Index ¶
- type BalanceStorageHandler
- type BalanceStorageHelper
- func (h *BalanceStorageHelper) AccountBalance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.Amount, error)
- func (h *BalanceStorageHelper) AddInterestingAddress(address string)
- func (h *BalanceStorageHelper) Asserter() *asserter.Asserter
- func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation
- type BroadcastStorageHandler
- func (h *BroadcastStorageHandler) BroadcastFailed(ctx context.Context, transactionIdentifier *types.TransactionIdentifier, ...) error
- func (h *BroadcastStorageHandler) TransactionConfirmed(ctx context.Context, blockIdentifier *types.BlockIdentifier, ...) error
- func (h *BroadcastStorageHandler) TransactionStale(ctx context.Context, transactionIdentifier *types.TransactionIdentifier) error
- type BroadcastStorageHelper
- func (h *BroadcastStorageHelper) AtTip(ctx context.Context, tipDelay int64) (bool, error)
- func (h *BroadcastStorageHelper) BroadcastTransaction(ctx context.Context, networkTransaction string) (*types.TransactionIdentifier, error)
- func (h *BroadcastStorageHelper) CurrentBlockIdentifier(ctx context.Context) (*types.BlockIdentifier, error)
- func (h *BroadcastStorageHelper) FindTransaction(ctx context.Context, transactionIdentifier *types.TransactionIdentifier, ...) (*types.BlockIdentifier, *types.Transaction, error)
- type ConstructorHandler
- type ConstructorHelper
- func (c *ConstructorHelper) AccountBalance(ctx context.Context, accountIdentifier *types.AccountIdentifier, ...) (*big.Int, error)
- func (c *ConstructorHelper) AllAddresses(ctx context.Context) ([]string, error)
- func (c *ConstructorHelper) AllBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
- func (c *ConstructorHelper) Broadcast(ctx context.Context, sender string, intent []*types.Operation, ...) error
- func (c *ConstructorHelper) ClearBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
- func (c *ConstructorHelper) CoinBalance(ctx context.Context, accountIdentifier *types.AccountIdentifier, ...) (*big.Int, *types.CoinIdentifier, error)
- func (c *ConstructorHelper) Combine(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (string, error)
- func (c *ConstructorHelper) Derive(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (string, map[string]interface{}, error)
- func (c *ConstructorHelper) Hash(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (*types.TransactionIdentifier, error)
- func (c *ConstructorHelper) LockedAddresses(ctx context.Context) ([]string, error)
- func (c *ConstructorHelper) Metadata(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (map[string]interface{}, error)
- func (c *ConstructorHelper) Parse(ctx context.Context, networkIdentifier *types.NetworkIdentifier, signed bool, ...) ([]*types.Operation, []string, map[string]interface{}, error)
- func (c *ConstructorHelper) Payloads(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (string, []*types.SigningPayload, error)
- func (c *ConstructorHelper) Preprocess(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (map[string]interface{}, error)
- func (c *ConstructorHelper) RandomAmount(min *big.Int, max *big.Int) *big.Int
- func (c *ConstructorHelper) Sign(ctx context.Context, payloads []*types.SigningPayload) ([]*types.Signature, error)
- func (c *ConstructorHelper) StoreKey(ctx context.Context, address string, keyPair *keys.KeyPair) error
- type ReconcilerHandler
- type ReconcilerHelper
- func (h *ReconcilerHelper) AccountBalance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.Amount, *types.BlockIdentifier, error)
- func (h *ReconcilerHelper) BlockExists(ctx context.Context, block *types.BlockIdentifier) (bool, error)
- func (h *ReconcilerHelper) CurrentBlock(ctx context.Context) (*types.BlockIdentifier, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceStorageHandler ¶ added in v0.4.0
type BalanceStorageHandler struct {
// contains filtered or unexported fields
}
BalanceStorageHandler is invoked whenever a block is added or removed from block storage so that balance changes can be sent to other functions (ex: reconciler).
func NewBalanceStorageHandler ¶ added in v0.4.0
func NewBalanceStorageHandler( logger *logger.Logger, reconciler *reconciler.Reconciler, reconcile bool, interestingAccount *reconciler.AccountCurrency, ) *BalanceStorageHandler
NewBalanceStorageHandler returns a new *BalanceStorageHandler.
func (*BalanceStorageHandler) BlockAdded ¶ added in v0.4.0
func (h *BalanceStorageHandler) BlockAdded( ctx context.Context, block *types.Block, changes []*parser.BalanceChange, ) error
BlockAdded is called whenever a block is committed to BlockStorage.
func (*BalanceStorageHandler) BlockRemoved ¶ added in v0.4.0
func (h *BalanceStorageHandler) BlockRemoved( ctx context.Context, block *types.Block, changes []*parser.BalanceChange, ) error
BlockRemoved is called whenever a block is removed from BlockStorage.
type BalanceStorageHelper ¶ added in v0.4.0
type BalanceStorageHelper struct {
// contains filtered or unexported fields
}
BalanceStorageHelper implements the storage.Helper interface.
func NewBalanceStorageHelper ¶ added in v0.4.0
func NewBalanceStorageHelper( network *types.NetworkIdentifier, fetcher *fetcher.Fetcher, lookupBalanceByBlock bool, exemptAccounts []*reconciler.AccountCurrency, interestingOnly bool, ) *BalanceStorageHelper
NewBalanceStorageHelper returns a new BalanceStorageHelper.
func (*BalanceStorageHelper) AccountBalance ¶ added in v0.4.0
func (h *BalanceStorageHelper) AccountBalance( ctx context.Context, account *types.AccountIdentifier, currency *types.Currency, block *types.BlockIdentifier, ) (*types.Amount, error)
AccountBalance attempts to fetch the balance for a missing account in storage. This is necessary for running the "check" command at an arbitrary height instead of syncing from genesis.
func (*BalanceStorageHelper) AddInterestingAddress ¶ added in v0.4.0
func (h *BalanceStorageHelper) AddInterestingAddress(address string)
AddInterestingAddress adds an address to track the balance of. This is often done after generating an account.
func (*BalanceStorageHelper) Asserter ¶ added in v0.4.0
func (h *BalanceStorageHelper) Asserter() *asserter.Asserter
Asserter returns a *asserter.Asserter.
func (*BalanceStorageHelper) ExemptFunc ¶ added in v0.4.0
func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation
ExemptFunc returns a parser.ExemptOperation.
type BroadcastStorageHandler ¶ added in v0.4.0
type BroadcastStorageHandler struct {
// contains filtered or unexported fields
}
BroadcastStorageHandler is invoked whenever a block is added or removed from block storage so that balance changes can be sent to other functions (ex: reconciler).
func NewBroadcastStorageHandler ¶ added in v0.4.0
func NewBroadcastStorageHandler( config *configuration.Configuration, counterStorage *storage.CounterStorage, parser *parser.Parser, ) *BroadcastStorageHandler
NewBroadcastStorageHandler returns a new *BroadcastStorageHandler.
func (*BroadcastStorageHandler) BroadcastFailed ¶ added in v0.4.0
func (h *BroadcastStorageHandler) BroadcastFailed( ctx context.Context, transactionIdentifier *types.TransactionIdentifier, intent []*types.Operation, ) error
BroadcastFailed is called when another transaction broadcast would put it over the provided broadcast limit.
func (*BroadcastStorageHandler) TransactionConfirmed ¶ added in v0.4.0
func (h *BroadcastStorageHandler) TransactionConfirmed( ctx context.Context, blockIdentifier *types.BlockIdentifier, transaction *types.Transaction, intent []*types.Operation, ) error
TransactionConfirmed is called when a transaction is observed on-chain for the last time at a block height < current block height - confirmationDepth.
func (*BroadcastStorageHandler) TransactionStale ¶ added in v0.4.0
func (h *BroadcastStorageHandler) TransactionStale( ctx context.Context, transactionIdentifier *types.TransactionIdentifier, ) error
TransactionStale is called when a transaction has not yet been seen on-chain and is considered stale. This occurs when current block height - last broadcast > staleDepth.
type BroadcastStorageHelper ¶ added in v0.4.0
type BroadcastStorageHelper struct {
// contains filtered or unexported fields
}
BroadcastStorageHelper implements the storage.Helper interface.
func NewBroadcastStorageHelper ¶ added in v0.4.0
func NewBroadcastStorageHelper( network *types.NetworkIdentifier, blockStorage *storage.BlockStorage, fetcher *fetcher.Fetcher, ) *BroadcastStorageHelper
NewBroadcastStorageHelper returns a new BroadcastStorageHelper.
func (*BroadcastStorageHelper) AtTip ¶ added in v0.4.0
AtTip is called before transaction broadcast to determine if we are at tip.
func (*BroadcastStorageHelper) BroadcastTransaction ¶ added in v0.4.0
func (h *BroadcastStorageHelper) BroadcastTransaction( ctx context.Context, networkTransaction string, ) (*types.TransactionIdentifier, error)
BroadcastTransaction broadcasts a transaction to a Rosetta implementation and returns the *types.TransactionIdentifier returned by the implementation.
func (*BroadcastStorageHelper) CurrentBlockIdentifier ¶ added in v0.4.0
func (h *BroadcastStorageHelper) CurrentBlockIdentifier( ctx context.Context, ) (*types.BlockIdentifier, error)
CurrentBlockIdentifier is called before transaction broadcast and is used to determine if a transaction broadcast is stale.
func (*BroadcastStorageHelper) FindTransaction ¶ added in v0.4.0
func (h *BroadcastStorageHelper) FindTransaction( ctx context.Context, transactionIdentifier *types.TransactionIdentifier, txn storage.DatabaseTransaction, ) (*types.BlockIdentifier, *types.Transaction, error)
FindTransaction looks for the provided TransactionIdentifier in processed blocks and returns the block identifier containing the most recent sighting and the transaction seen in that block.
type ConstructorHandler ¶ added in v0.4.0
type ConstructorHandler struct {
// contains filtered or unexported fields
}
ConstructorHandler is invoked by the Constructor when addresses are created or transactions are created.
func NewConstructorHandler ¶ added in v0.4.0
func NewConstructorHandler( balanceStorageHelper *BalanceStorageHelper, counterStorage *storage.CounterStorage, ) *ConstructorHandler
NewConstructorHandler returns a new *ConstructorHandler.
func (*ConstructorHandler) AddressCreated ¶ added in v0.4.0
func (h *ConstructorHandler) AddressCreated(ctx context.Context, address string) error
AddressCreated adds an address to balance tracking.
func (*ConstructorHandler) TransactionCreated ¶ added in v0.4.0
func (h *ConstructorHandler) TransactionCreated( ctx context.Context, sender string, transactionIdentifier *types.TransactionIdentifier, ) error
TransactionCreated increments the TransactionsCreatedCounter in CounterStorage.
type ConstructorHelper ¶ added in v0.4.0
type ConstructorHelper struct {
// contains filtered or unexported fields
}
ConstructorHelper implements the constructor.Helper interface.
func NewConstructorHelper ¶ added in v0.4.0
func NewConstructorHelper( offlineFetcher *fetcher.Fetcher, onlineFetcher *fetcher.Fetcher, keyStorage *storage.KeyStorage, balanceStorage *storage.BalanceStorage, coinStorage *storage.CoinStorage, broadcastStorage *storage.BroadcastStorage, ) *ConstructorHelper
NewConstructorHelper returns a new *ConstructorHelper.
func (*ConstructorHelper) AccountBalance ¶ added in v0.4.0
func (c *ConstructorHelper) AccountBalance( ctx context.Context, accountIdentifier *types.AccountIdentifier, currency *types.Currency, ) (*big.Int, error)
AccountBalance returns the balance for a provided address using BalanceStorage. If the address balance does not exist, 0 will be returned.
func (*ConstructorHelper) AllAddresses ¶ added in v0.4.0
func (c *ConstructorHelper) AllAddresses(ctx context.Context) ([]string, error)
AllAddresses returns a slice of all known addresses.
func (*ConstructorHelper) AllBroadcasts ¶ added in v0.4.0
AllBroadcasts returns a slice of all in-progress broadcasts in BroadcastStorage.
func (*ConstructorHelper) Broadcast ¶ added in v0.4.0
func (c *ConstructorHelper) Broadcast( ctx context.Context, sender string, intent []*types.Operation, transactionIdentifier *types.TransactionIdentifier, payload string, ) error
Broadcast enqueues a particular intent for broadcast.
func (*ConstructorHelper) ClearBroadcasts ¶ added in v0.4.0
ClearBroadcasts deletes all pending broadcasts.
func (*ConstructorHelper) CoinBalance ¶ added in v0.4.0
func (c *ConstructorHelper) CoinBalance( ctx context.Context, accountIdentifier *types.AccountIdentifier, currency *types.Currency, ) (*big.Int, *types.CoinIdentifier, error)
CoinBalance returns the balance of the largest Coin owned by an address.
func (*ConstructorHelper) Combine ¶ added in v0.4.0
func (c *ConstructorHelper) Combine( ctx context.Context, networkIdentifier *types.NetworkIdentifier, unsignedTransaction string, signatures []*types.Signature, ) (string, error)
Combine calls the /construction/combine endpoint using the offline node.
func (*ConstructorHelper) Derive ¶ added in v0.4.0
func (c *ConstructorHelper) Derive( ctx context.Context, networkIdentifier *types.NetworkIdentifier, publicKey *types.PublicKey, metadata map[string]interface{}, ) (string, map[string]interface{}, error)
Derive returns a new address for a provided publicKey.
func (*ConstructorHelper) Hash ¶ added in v0.4.0
func (c *ConstructorHelper) Hash( ctx context.Context, networkIdentifier *types.NetworkIdentifier, networkTransaction string, ) (*types.TransactionIdentifier, error)
Hash calls the /construction/hash endpoint using the offline node.
func (*ConstructorHelper) LockedAddresses ¶ added in v0.4.0
func (c *ConstructorHelper) LockedAddresses(ctx context.Context) ([]string, error)
LockedAddresses returns a slice of all addresses currently sending or receiving funds.
func (*ConstructorHelper) Metadata ¶ added in v0.4.0
func (c *ConstructorHelper) Metadata( ctx context.Context, networkIdentifier *types.NetworkIdentifier, metadataRequest map[string]interface{}, ) (map[string]interface{}, error)
Metadata calls the /construction/metadata endpoint using the online node.
func (*ConstructorHelper) Parse ¶ added in v0.4.0
func (c *ConstructorHelper) Parse( ctx context.Context, networkIdentifier *types.NetworkIdentifier, signed bool, transaction string, ) ([]*types.Operation, []string, map[string]interface{}, error)
Parse calls the /construction/parse endpoint using the offline node.
func (*ConstructorHelper) Payloads ¶ added in v0.4.0
func (c *ConstructorHelper) Payloads( ctx context.Context, networkIdentifier *types.NetworkIdentifier, intent []*types.Operation, requiredMetadata map[string]interface{}, ) (string, []*types.SigningPayload, error)
Payloads calls the /construction/payloads endpoint using the offline node.
func (*ConstructorHelper) Preprocess ¶ added in v0.4.0
func (c *ConstructorHelper) Preprocess( ctx context.Context, networkIdentifier *types.NetworkIdentifier, intent []*types.Operation, metadata map[string]interface{}, ) (map[string]interface{}, error)
Preprocess calls the /construction/preprocess endpoint on an offline node.
func (*ConstructorHelper) RandomAmount ¶ added in v0.4.0
RandomAmount returns some integer between min and max.
func (*ConstructorHelper) Sign ¶ added in v0.4.0
func (c *ConstructorHelper) Sign( ctx context.Context, payloads []*types.SigningPayload, ) ([]*types.Signature, error)
Sign invokes the KeyStorage backend to sign some payloads.
type ReconcilerHandler ¶
type ReconcilerHandler struct {
InactiveFailure *reconciler.AccountCurrency
InactiveFailureBlock *types.BlockIdentifier
ActiveFailureBlock *types.BlockIdentifier
// contains filtered or unexported fields
}
ReconcilerHandler implements the Reconciler.Handler interface.
func NewReconcilerHandler ¶
func NewReconcilerHandler( logger *logger.Logger, haltOnReconciliationError bool, ) *ReconcilerHandler
NewReconcilerHandler creates a new ReconcilerHandler.
func (*ReconcilerHandler) ReconciliationFailed ¶
func (h *ReconcilerHandler) ReconciliationFailed( ctx context.Context, reconciliationType string, account *types.AccountIdentifier, currency *types.Currency, computedBalance string, nodeBalance string, block *types.BlockIdentifier, ) error
ReconciliationFailed is called each time a reconciliation fails. In this Handler implementation, we halt if haltOnReconciliationError was set to true. We also cancel the context.
func (*ReconcilerHandler) ReconciliationSucceeded ¶
func (h *ReconcilerHandler) ReconciliationSucceeded( ctx context.Context, reconciliationType string, account *types.AccountIdentifier, currency *types.Currency, balance string, block *types.BlockIdentifier, ) error
ReconciliationSucceeded is called each time a reconciliation succeeds.
type ReconcilerHelper ¶
type ReconcilerHelper struct {
// contains filtered or unexported fields
}
ReconcilerHelper implements the Reconciler.Helper interface.
func NewReconcilerHelper ¶
func NewReconcilerHelper( blockStorage *storage.BlockStorage, balanceStorage *storage.BalanceStorage, ) *ReconcilerHelper
NewReconcilerHelper returns a new ReconcilerHelper.
func (*ReconcilerHelper) AccountBalance ¶
func (h *ReconcilerHelper) AccountBalance( ctx context.Context, account *types.AccountIdentifier, currency *types.Currency, headBlock *types.BlockIdentifier, ) (*types.Amount, *types.BlockIdentifier, error)
AccountBalance returns the balance of an account in block storage. It is necessary to perform this check outside of the Reconciler package to allow for separation from a default storage backend.
func (*ReconcilerHelper) BlockExists ¶
func (h *ReconcilerHelper) BlockExists( ctx context.Context, block *types.BlockIdentifier, ) (bool, error)
BlockExists returns a boolean indicating if block_storage contains a block. This is necessary to reconcile across reorgs. If the block returned on an account balance fetch does not exist, reconciliation will be skipped.
func (*ReconcilerHelper) CurrentBlock ¶
func (h *ReconcilerHelper) CurrentBlock( ctx context.Context, ) (*types.BlockIdentifier, error)
CurrentBlock returns the last processed block and is used to determine which block to check account balances at during inactive reconciliation.