Documentation
¶
Index ¶
- Variables
- 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, dbTx storage.DatabaseTransaction, identifier string, ...) error
- func (h *BroadcastStorageHandler) TransactionConfirmed(ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, ...) error
- func (h *BroadcastStorageHandler) TransactionStale(ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, ...) error
- type BroadcastStorageHelper
- func (h *BroadcastStorageHelper) AtTip(ctx context.Context, tipDelay int64) (bool, error)
- func (h *BroadcastStorageHelper) BroadcastTransaction(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (*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 CoinStorageHelper
- type CoordinatorHandler
- type CoordinatorHelper
- func (c *CoordinatorHelper) AllAccounts(ctx context.Context, dbTx storage.DatabaseTransaction) ([]*types.AccountIdentifier, error)
- func (c *CoordinatorHelper) AllBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
- func (c *CoordinatorHelper) Balance(ctx context.Context, dbTx storage.DatabaseTransaction, ...) (*types.Amount, error)
- func (c *CoordinatorHelper) Broadcast(ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, ...) error
- func (c *CoordinatorHelper) BroadcastAll(ctx context.Context) error
- func (c *CoordinatorHelper) ClearBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
- func (c *CoordinatorHelper) Coins(ctx context.Context, dbTx storage.DatabaseTransaction, ...) ([]*types.Coin, error)
- func (c *CoordinatorHelper) Combine(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (string, error)
- func (c *CoordinatorHelper) DatabaseTransaction(ctx context.Context) storage.DatabaseTransaction
- func (c *CoordinatorHelper) Derive(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (*types.AccountIdentifier, map[string]interface{}, error)
- func (c *CoordinatorHelper) GetKey(ctx context.Context, dbTx storage.DatabaseTransaction, ...) (*keys.KeyPair, error)
- func (c *CoordinatorHelper) Hash(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (*types.TransactionIdentifier, error)
- func (c *CoordinatorHelper) HeadBlockExists(ctx context.Context) bool
- func (c *CoordinatorHelper) LockedAccounts(ctx context.Context, dbTx storage.DatabaseTransaction) ([]*types.AccountIdentifier, error)
- func (c *CoordinatorHelper) Metadata(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (map[string]interface{}, []*types.Amount, error)
- func (c *CoordinatorHelper) Parse(ctx context.Context, networkIdentifier *types.NetworkIdentifier, signed bool, ...) ([]*types.Operation, []*types.AccountIdentifier, map[string]interface{}, error)
- func (c *CoordinatorHelper) Payloads(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (string, []*types.SigningPayload, error)
- func (c *CoordinatorHelper) Preprocess(ctx context.Context, networkIdentifier *types.NetworkIdentifier, ...) (map[string]interface{}, []*types.AccountIdentifier, error)
- func (c *CoordinatorHelper) Sign(ctx context.Context, payloads []*types.SigningPayload) ([]*types.Signature, error)
- func (c *CoordinatorHelper) StoreKey(ctx context.Context, dbTx storage.DatabaseTransaction, ...) error
- type ReconcilerHandler
- type ReconcilerHelper
- func (h *ReconcilerHelper) BlockExists(ctx context.Context, block *types.BlockIdentifier) (bool, error)
- func (h *ReconcilerHelper) ComputedBalance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.Amount, *types.BlockIdentifier, error)
- func (h *ReconcilerHelper) CurrentBlock(ctx context.Context) (*types.BlockIdentifier, error)
- func (h *ReconcilerHelper) LiveBalance(ctx context.Context, account *types.AccountIdentifier, ...) (*types.Amount, *types.BlockIdentifier, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrReconciliationFailure is returned if reconciliation fails. ErrReconciliationFailure = errors.New("reconciliation failure") )
Functions ¶
This section is empty.
Types ¶
type BalanceStorageHandler ¶
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 ¶
func NewBalanceStorageHandler( logger *logger.Logger, reconciler *reconciler.Reconciler, reconcile bool, interestingAccount *reconciler.AccountCurrency, ) *BalanceStorageHandler
NewBalanceStorageHandler returns a new *BalanceStorageHandler.
func (*BalanceStorageHandler) BlockAdded ¶
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 ¶
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 ¶
type BalanceStorageHelper struct {
// contains filtered or unexported fields
}
BalanceStorageHelper implements the storage.Helper interface.
func NewBalanceStorageHelper ¶
func NewBalanceStorageHelper( network *types.NetworkIdentifier, fetcher *fetcher.Fetcher, lookupBalanceByBlock bool, exemptAccounts []*reconciler.AccountCurrency, interestingOnly bool, ) *BalanceStorageHelper
NewBalanceStorageHelper returns a new BalanceStorageHelper.
func (*BalanceStorageHelper) AccountBalance ¶
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 ¶
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 ¶
func (h *BalanceStorageHelper) Asserter() *asserter.Asserter
Asserter returns a *asserter.Asserter.
func (*BalanceStorageHelper) ExemptFunc ¶
func (h *BalanceStorageHelper) ExemptFunc() parser.ExemptOperation
ExemptFunc returns a parser.ExemptOperation.
type BroadcastStorageHandler ¶
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 ¶
func NewBroadcastStorageHandler( config *configuration.Configuration, counterStorage *storage.CounterStorage, coordinator *coordinator.Coordinator, parser *parser.Parser, ) *BroadcastStorageHandler
NewBroadcastStorageHandler returns a new *BroadcastStorageHandler.
func (*BroadcastStorageHandler) BroadcastFailed ¶
func (h *BroadcastStorageHandler) BroadcastFailed( ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, 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 ¶
func (h *BroadcastStorageHandler) TransactionConfirmed( ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, 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 ¶
func (h *BroadcastStorageHandler) TransactionStale( ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, 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 ¶
type BroadcastStorageHelper struct {
// contains filtered or unexported fields
}
BroadcastStorageHelper implements the storage.Helper interface.
func NewBroadcastStorageHelper ¶
func NewBroadcastStorageHelper( blockStorage *storage.BlockStorage, fetcher *fetcher.Fetcher, ) *BroadcastStorageHelper
NewBroadcastStorageHelper returns a new BroadcastStorageHelper.
func (*BroadcastStorageHelper) AtTip ¶
AtTip is called before transaction broadcast to determine if we are at tip.
func (*BroadcastStorageHelper) BroadcastTransaction ¶
func (h *BroadcastStorageHelper) BroadcastTransaction( ctx context.Context, networkIdentifier *types.NetworkIdentifier, 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 ¶
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 ¶
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 CoinStorageHelper ¶
type CoinStorageHelper struct {
// contains filtered or unexported fields
}
CoinStorageHelper implements the storage.CoinStorageHelper interface.
func NewCoinStorageHelper ¶
func NewCoinStorageHelper(blockStorage *storage.BlockStorage) *CoinStorageHelper
NewCoinStorageHelper returns a new *CoinStorageHelper.
func (*CoinStorageHelper) CurrentBlockIdentifier ¶
func (c *CoinStorageHelper) CurrentBlockIdentifier( ctx context.Context, transaction storage.DatabaseTransaction, ) (*types.BlockIdentifier, error)
CurrentBlockIdentifier returns the head *types.BlockIdentifier in the context of a storage.DatabaseTransaction.
type CoordinatorHandler ¶ added in v0.5.0
type CoordinatorHandler struct {
// contains filtered or unexported fields
}
CoordinatorHandler is invoked by the Coordinator when addresses are created or transactions are created.
func NewCoordinatorHandler ¶ added in v0.5.0
func NewCoordinatorHandler( counterStorage *storage.CounterStorage, ) *CoordinatorHandler
NewCoordinatorHandler returns a new *CoordinatorHandler.
func (*CoordinatorHandler) TransactionCreated ¶ added in v0.5.0
func (h *CoordinatorHandler) TransactionCreated( ctx context.Context, jobIdentifier string, transactionIdentifier *types.TransactionIdentifier, ) error
TransactionCreated increments the TransactionsCreatedCounter in CounterStorage.
type CoordinatorHelper ¶ added in v0.5.0
type CoordinatorHelper struct {
// contains filtered or unexported fields
}
CoordinatorHelper implements the Coordinator.Helper interface.
func NewCoordinatorHelper ¶ added in v0.5.0
func NewCoordinatorHelper( offlineFetcher *fetcher.Fetcher, onlineFetcher *fetcher.Fetcher, database storage.Database, blockStorage *storage.BlockStorage, keyStorage *storage.KeyStorage, balanceStorage *storage.BalanceStorage, coinStorage *storage.CoinStorage, broadcastStorage *storage.BroadcastStorage, balanceStorageHelper *BalanceStorageHelper, counterStorage *storage.CounterStorage, ) *CoordinatorHelper
NewCoordinatorHelper returns a new *CoordinatorHelper.
func (*CoordinatorHelper) AllAccounts ¶ added in v0.5.1
func (c *CoordinatorHelper) AllAccounts( ctx context.Context, dbTx storage.DatabaseTransaction, ) ([]*types.AccountIdentifier, error)
AllAccounts returns a slice of all known accounts.
func (*CoordinatorHelper) AllBroadcasts ¶ added in v0.5.0
AllBroadcasts returns a slice of all in-progress broadcasts in BroadcastStorage.
func (*CoordinatorHelper) Balance ¶ added in v0.5.0
func (c *CoordinatorHelper) Balance( ctx context.Context, dbTx storage.DatabaseTransaction, accountIdentifier *types.AccountIdentifier, currency *types.Currency, ) (*types.Amount, error)
Balance returns the balance for a provided address using BalanceStorage. If the address balance does not exist, 0 will be returned.
func (*CoordinatorHelper) Broadcast ¶ added in v0.5.0
func (c *CoordinatorHelper) Broadcast( ctx context.Context, dbTx storage.DatabaseTransaction, identifier string, network *types.NetworkIdentifier, intent []*types.Operation, transactionIdentifier *types.TransactionIdentifier, payload string, confirmationDepth int64, ) error
Broadcast enqueues a particular intent for broadcast.
func (*CoordinatorHelper) BroadcastAll ¶ added in v0.5.0
func (c *CoordinatorHelper) BroadcastAll( ctx context.Context, ) error
BroadcastAll attempts to broadcast all ready transactions.
func (*CoordinatorHelper) ClearBroadcasts ¶ added in v0.5.0
ClearBroadcasts deletes all pending broadcasts.
func (*CoordinatorHelper) Coins ¶ added in v0.5.0
func (c *CoordinatorHelper) Coins( ctx context.Context, dbTx storage.DatabaseTransaction, accountIdentifier *types.AccountIdentifier, currency *types.Currency, ) ([]*types.Coin, error)
Coins returns all *types.Coin owned by an account.
func (*CoordinatorHelper) Combine ¶ added in v0.5.0
func (c *CoordinatorHelper) 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 (*CoordinatorHelper) DatabaseTransaction ¶ added in v0.5.0
func (c *CoordinatorHelper) DatabaseTransaction(ctx context.Context) storage.DatabaseTransaction
DatabaseTransaction returns a new write-ready storage.DatabaseTransaction.
func (*CoordinatorHelper) Derive ¶ added in v0.5.0
func (c *CoordinatorHelper) Derive( ctx context.Context, networkIdentifier *types.NetworkIdentifier, publicKey *types.PublicKey, metadata map[string]interface{}, ) (*types.AccountIdentifier, map[string]interface{}, error)
Derive returns a new address for a provided publicKey.
func (*CoordinatorHelper) GetKey ¶ added in v0.5.1
func (c *CoordinatorHelper) GetKey( ctx context.Context, dbTx storage.DatabaseTransaction, account *types.AccountIdentifier, ) (*keys.KeyPair, error)
GetKey is called to get the *types.KeyPair associated with an address.
func (*CoordinatorHelper) Hash ¶ added in v0.5.0
func (c *CoordinatorHelper) Hash( ctx context.Context, networkIdentifier *types.NetworkIdentifier, networkTransaction string, ) (*types.TransactionIdentifier, error)
Hash calls the /construction/hash endpoint using the offline node.
func (*CoordinatorHelper) HeadBlockExists ¶ added in v0.5.0
func (c *CoordinatorHelper) HeadBlockExists(ctx context.Context) bool
HeadBlockExists returns a boolean indicating if a block has been synced by BlockStorage.
func (*CoordinatorHelper) LockedAccounts ¶ added in v0.5.1
func (c *CoordinatorHelper) LockedAccounts( ctx context.Context, dbTx storage.DatabaseTransaction, ) ([]*types.AccountIdentifier, error)
LockedAccounts returns a slice of all accounts currently sending or receiving funds.
func (*CoordinatorHelper) Metadata ¶ added in v0.5.0
func (c *CoordinatorHelper) Metadata( ctx context.Context, networkIdentifier *types.NetworkIdentifier, metadataRequest map[string]interface{}, publicKeys []*types.PublicKey, ) (map[string]interface{}, []*types.Amount, error)
Metadata calls the /construction/metadata endpoint using the online node.
func (*CoordinatorHelper) Parse ¶ added in v0.5.0
func (c *CoordinatorHelper) Parse( ctx context.Context, networkIdentifier *types.NetworkIdentifier, signed bool, transaction string, ) ([]*types.Operation, []*types.AccountIdentifier, map[string]interface{}, error)
Parse calls the /construction/parse endpoint using the offline node.
func (*CoordinatorHelper) Payloads ¶ added in v0.5.0
func (c *CoordinatorHelper) Payloads( ctx context.Context, networkIdentifier *types.NetworkIdentifier, intent []*types.Operation, requiredMetadata map[string]interface{}, publicKeys []*types.PublicKey, ) (string, []*types.SigningPayload, error)
Payloads calls the /construction/payloads endpoint using the offline node.
func (*CoordinatorHelper) Preprocess ¶ added in v0.5.0
func (c *CoordinatorHelper) Preprocess( ctx context.Context, networkIdentifier *types.NetworkIdentifier, intent []*types.Operation, metadata map[string]interface{}, ) (map[string]interface{}, []*types.AccountIdentifier, error)
Preprocess calls the /construction/preprocess endpoint on an offline node.
func (*CoordinatorHelper) Sign ¶ added in v0.5.0
func (c *CoordinatorHelper) Sign( ctx context.Context, payloads []*types.SigningPayload, ) ([]*types.Signature, error)
Sign invokes the KeyStorage backend to sign some payloads.
func (*CoordinatorHelper) StoreKey ¶ added in v0.5.0
func (c *CoordinatorHelper) StoreKey( ctx context.Context, dbTx storage.DatabaseTransaction, account *types.AccountIdentifier, keyPair *keys.KeyPair, ) error
StoreKey stores a KeyPair and address in KeyStorage.
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, balanceStorage *storage.BalanceStorage, 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( network *types.NetworkIdentifier, fetcher *fetcher.Fetcher, blockStorage *storage.BlockStorage, balanceStorage *storage.BalanceStorage, ) *ReconcilerHelper
NewReconcilerHelper returns a new ReconcilerHelper.
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) ComputedBalance ¶ added in v0.5.0
func (h *ReconcilerHelper) ComputedBalance( ctx context.Context, account *types.AccountIdentifier, currency *types.Currency, headBlock *types.BlockIdentifier, ) (*types.Amount, *types.BlockIdentifier, error)
ComputedBalance 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) 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.
func (*ReconcilerHelper) LiveBalance ¶ added in v0.5.0
func (h *ReconcilerHelper) LiveBalance( ctx context.Context, account *types.AccountIdentifier, currency *types.Currency, headBlock *types.BlockIdentifier, ) (*types.Amount, *types.BlockIdentifier, error)
LiveBalance returns the live balance of an account.