Documentation ¶
Index ¶
- Constants
- type BlockAndLatency
- type Fetcher
- func (f *Fetcher) AccountBalance(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
- func (f *Fetcher) AccountBalanceRetry(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
- func (f *Fetcher) Block(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Block, error)
- func (f *Fetcher) BlockRange(ctx context.Context, network *rosetta.NetworkIdentifier, startIndex int64, ...) (map[int64]*BlockAndLatency, error)
- func (f *Fetcher) BlockRetry(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Block, error)
- func (f *Fetcher) ConstructionMetadata(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Amount, *map[string]interface{}, error)
- func (f *Fetcher) ConstructionSubmit(ctx context.Context, signedTransaction string) (*rosetta.TransactionIdentifier, *string, *map[string]interface{}, error)
- func (f *Fetcher) InitializeAsserter(ctx context.Context) (*rosetta.NetworkStatusResponse, error)
- func (f *Fetcher) Mempool(ctx context.Context, network *rosetta.NetworkIdentifier) ([]*rosetta.TransactionIdentifier, error)
- func (f *Fetcher) MempoolTransaction(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Transaction, *map[string]interface{}, error)
- func (f *Fetcher) NetworkStatus(ctx context.Context, metadata *map[string]interface{}) (*rosetta.NetworkStatusResponse, error)
- func (f *Fetcher) NetworkStatusRetry(ctx context.Context, metadata *map[string]interface{}, ...) (*rosetta.NetworkStatusResponse, error)
- func (f *Fetcher) UnsafeAccountBalance(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
- func (f *Fetcher) UnsafeBlock(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Block, error)
- func (f *Fetcher) UnsafeMempool(ctx context.Context, network *rosetta.NetworkIdentifier) ([]*rosetta.TransactionIdentifier, error)
- func (f *Fetcher) UnsafeMempoolTransaction(ctx context.Context, network *rosetta.NetworkIdentifier, ...) (*rosetta.Transaction, *map[string]interface{}, error)
- func (f *Fetcher) UnsafeNetworkStatus(ctx context.Context, metadata *map[string]interface{}) (*rosetta.NetworkStatusResponse, error)
- func (f *Fetcher) UnsafeTransactions(ctx context.Context, network *rosetta.NetworkIdentifier, ...) ([]*rosetta.Transaction, error)
Constants ¶
const ( // DefaultElapsedTime is the default limit on time // spent retrying a fetch. DefaultElapsedTime = 1 * time.Minute // DefaultRetries is the default number of times to // attempt a retry on a failed request. DefaultRetries = 10 // DefaultBlockConcurrency is the default number of // blocks a Fetcher will try to get concurrently. DefaultBlockConcurrency = 8 // DefaultTransactionConcurrency is the default // number of transactions a Fetcher will try to // get concurrently when populating a block (if // transactions are not included in the original // block fetch). DefaultTransactionConcurrency = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockAndLatency ¶
BlockAndLatency is utilized to track the latency of concurrent block fetches.
type Fetcher ¶
type Fetcher struct { // Asserter is a public variable because // it can be used to determine if a retrieved // rosetta.Operation is successful and should // be applied. Asserter *asserter.Asserter // contains filtered or unexported fields }
Fetcher contains all logic to communicate with a Rosetta Server.
func New ¶
func New( ctx context.Context, serverAddress string, userAgent string, httpClient *http.Client, blockConcurrency uint64, transactionConcurrency uint64, ) *Fetcher
New constructs a new Fetcher.
func (*Fetcher) AccountBalance ¶
func (f *Fetcher) AccountBalance( ctx context.Context, network *rosetta.NetworkIdentifier, account *rosetta.AccountIdentifier, ) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
AccountBalance returns the validated response from the AccountBalance method.
func (*Fetcher) AccountBalanceRetry ¶
func (f *Fetcher) AccountBalanceRetry( ctx context.Context, network *rosetta.NetworkIdentifier, account *rosetta.AccountIdentifier, maxElapsedTime time.Duration, maxRetries uint64, ) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
AccountBalanceRetry retrieves the validated AccountBalance with a specified number of retries and max elapsed time.
func (*Fetcher) Block ¶
func (f *Fetcher) Block( ctx context.Context, network *rosetta.NetworkIdentifier, blockIdentifier *rosetta.PartialBlockIdentifier, ) (*rosetta.Block, error)
Block returns the validated response from the block method. This function will automatically fetch any transactions that were not returned by the call to fetch the block.
func (*Fetcher) BlockRange ¶
func (f *Fetcher) BlockRange( ctx context.Context, network *rosetta.NetworkIdentifier, startIndex int64, endIndex int64, ) (map[int64]*BlockAndLatency, error)
BlockRange concurrently fetches blocks from startIndex to endIndex, inclusive. Blocks returned by this method may not contain a path from the endBlock to the startBlock over Block.ParentBlockIdentifers if a re-org occurs during the fetch. This should be handled gracefully by any callers.
func (*Fetcher) BlockRetry ¶
func (f *Fetcher) BlockRetry( ctx context.Context, network *rosetta.NetworkIdentifier, blockIdentifier *rosetta.PartialBlockIdentifier, maxElapsedTime time.Duration, maxRetries uint64, ) (*rosetta.Block, error)
BlockRetry retrieves a validated Block with a specified number of retries and max elapsed time.
func (*Fetcher) ConstructionMetadata ¶
func (f *Fetcher) ConstructionMetadata( ctx context.Context, network *rosetta.NetworkIdentifier, account *rosetta.AccountIdentifier, method *string, ) (*rosetta.Amount, *map[string]interface{}, error)
ConstructionMetadata returns the validated response from the ConstructionMetadata method.
func (*Fetcher) ConstructionSubmit ¶
func (f *Fetcher) ConstructionSubmit( ctx context.Context, signedTransaction string, ) (*rosetta.TransactionIdentifier, *string, *map[string]interface{}, error)
ConstructionSubmit returns the validated response from the ConstructionSubmit method.
func (*Fetcher) InitializeAsserter ¶
func (f *Fetcher) InitializeAsserter( ctx context.Context, ) (*rosetta.NetworkStatusResponse, error)
InitializeAsserter creates an Asserter for validating responses. The Asserter is created from a rosetta.NetworkStatusResponse. This method should be called before making any validated client requests.
func (*Fetcher) Mempool ¶
func (f *Fetcher) Mempool( ctx context.Context, network *rosetta.NetworkIdentifier, ) ([]*rosetta.TransactionIdentifier, error)
Mempool returns the validated response from the Mempool method.
func (*Fetcher) MempoolTransaction ¶
func (f *Fetcher) MempoolTransaction( ctx context.Context, network *rosetta.NetworkIdentifier, transaction *rosetta.TransactionIdentifier, ) (*rosetta.Transaction, *map[string]interface{}, error)
MempoolTransaction returns the validated response from the MempoolTransaction method.
func (*Fetcher) NetworkStatus ¶
func (f *Fetcher) NetworkStatus( ctx context.Context, metadata *map[string]interface{}, ) (*rosetta.NetworkStatusResponse, error)
NetworkStatus returns the validated response from the NetworkStatus method.
func (*Fetcher) NetworkStatusRetry ¶
func (f *Fetcher) NetworkStatusRetry( ctx context.Context, metadata *map[string]interface{}, maxElapsedTime time.Duration, maxRetries uint64, ) (*rosetta.NetworkStatusResponse, error)
NetworkStatusRetry retrieves the validated NetworkStatus with a specified number of retries and max elapsed time.
func (*Fetcher) UnsafeAccountBalance ¶
func (f *Fetcher) UnsafeAccountBalance( ctx context.Context, network *rosetta.NetworkIdentifier, account *rosetta.AccountIdentifier, ) (*rosetta.BlockIdentifier, []*rosetta.Balance, error)
UnsafeAccountBalance returns the unvalidated response from the AccountBalance method.
func (*Fetcher) UnsafeBlock ¶
func (f *Fetcher) UnsafeBlock( ctx context.Context, network *rosetta.NetworkIdentifier, blockIdentifier *rosetta.PartialBlockIdentifier, ) (*rosetta.Block, error)
UnsafeBlock returns the unvalidated response from the Block method. This function will automatically fetch any transactions that were not returned by the call to fetch the block.
func (*Fetcher) UnsafeMempool ¶
func (f *Fetcher) UnsafeMempool( ctx context.Context, network *rosetta.NetworkIdentifier, ) ([]*rosetta.TransactionIdentifier, error)
UnsafeMempool returns the unvalidated response from the Mempool method.
func (*Fetcher) UnsafeMempoolTransaction ¶
func (f *Fetcher) UnsafeMempoolTransaction( ctx context.Context, network *rosetta.NetworkIdentifier, transaction *rosetta.TransactionIdentifier, ) (*rosetta.Transaction, *map[string]interface{}, error)
UnsafeMempoolTransaction returns the unvalidated response from the MempoolTransaction method.
func (*Fetcher) UnsafeNetworkStatus ¶
func (f *Fetcher) UnsafeNetworkStatus( ctx context.Context, metadata *map[string]interface{}, ) (*rosetta.NetworkStatusResponse, error)
UnsafeNetworkStatus returns the unvalidated response from the NetworkStatus method.
func (*Fetcher) UnsafeTransactions ¶
func (f *Fetcher) UnsafeTransactions( ctx context.Context, network *rosetta.NetworkIdentifier, block *rosetta.BlockIdentifier, transactionIdentifiers []*rosetta.TransactionIdentifier, ) ([]*rosetta.Transaction, error)
UnsafeTransactions returns the unvalidated response from the BlockTransaction method. UnsafeTransactions fetches all provided rosetta.TransactionIdentifiers concurrently (with the number of threads specified by txConcurrency). If any fetch fails, this function will return an error.