impl

package
v0.0.1-alpha-3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT, Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNonceStore

func NewNonceStore(systemStore sqlstore.SystemStore) nonce.NonceStore

NewNonceStore creates a new nonce store.

func NewSimpleTracker

func NewSimpleTracker(w *wallet.Wallet, backend bind.ContractBackend) nonce.NonceTracker

NewSimpleTracker returns a Simpler Tracker.

Types

type LocalTracker

type LocalTracker struct {
	// contains filtered or unexported fields
}

LocalTracker implements a nonce tracker that stores nonce and pending txs locally.

func NewLocalTracker

func NewLocalTracker(
	ctx context.Context,
	w *wallet.Wallet,
	nonceStore noncepkg.NonceStore,
	chainID tableland.ChainID,
	chainClient noncepkg.ChainClient,
	checkInterval time.Duration,
	minBlockChainDepth int,
	stuckInterval time.Duration,
) (*LocalTracker, error)

NewLocalTracker creates a new local tracker. The provided context is used only for initialization logic. For graceful closing, the caller should use the Close() API.

func (*LocalTracker) Close

func (t *LocalTracker) Close()

Close closes the background goroutine.

func (*LocalTracker) GetNonce

GetNonce returns the nonce to be used in the next transaction. The call is blocked until the client calls unlock. The client should also call registerPendingTx if it managed to submit a transaction sucessuflly.

func (*LocalTracker) GetPendingCount

func (t *LocalTracker) GetPendingCount(_ context.Context) int

GetPendingCount returns the number of pendings txs.

func (*LocalTracker) Resync

func (t *LocalTracker) Resync(ctx context.Context) error

Resync resyncs nonce tracker state with the network. NOTICE: must not call `Resync(..)` if there are still an "open call" to the method `GetNonce(...)`.

type NonceStore

type NonceStore struct {
	// contains filtered or unexported fields
}

NonceStore relies on the SQLStore implementation for now.

func (*NonceStore) DeletePendingTxByHash

func (s *NonceStore) DeletePendingTxByHash(ctx context.Context, hash common.Hash) error

DeletePendingTxByHash deletes a pending tx.

func (*NonceStore) InsertPendingTx

func (s *NonceStore) InsertPendingTx(
	ctx context.Context,
	addr common.Address,
	nonce int64, hash common.Hash,
) error

InsertPendingTx insert a new pending tx.

func (*NonceStore) ListPendingTx

func (s *NonceStore) ListPendingTx(
	ctx context.Context,
	addr common.Address,
) ([]nonce.PendingTx, error)

ListPendingTx lists all pendings txs.

func (*NonceStore) ReplacePendingTxByHash

func (s *NonceStore) ReplacePendingTxByHash(ctx context.Context, oldHash common.Hash, newHash common.Hash) error

ReplacePendingTxByHash replaces a pending tx hash with another and also bumps the counter to track how many times this happened for this nonce.

type SimpleTracker

type SimpleTracker struct {
	// contains filtered or unexported fields
}

SimpleTracker is a nonce tracker for testing purposes.

func (*SimpleTracker) GetNonce

GetNonce returns the nonce to be used in the next transaction.

func (*SimpleTracker) GetPendingCount

func (t *SimpleTracker) GetPendingCount(_ context.Context) int

GetPendingCount returns the number of pendings txs.

func (*SimpleTracker) Resync

func (t *SimpleTracker) Resync(_ context.Context) error

Resync is a noop for SimpleTracker.

Jump to

Keyboard shortcuts

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