balance

package
v0.166.11 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache() *Cache

func (*Cache) AddBalance

func (b *Cache) AddBalance(account common.Address, chainID uint64, blockNumber *big.Int, balance *big.Int)

func (*Cache) AddNonce

func (b *Cache) AddNonce(account common.Address, chainID uint64, blockNumber *big.Int, nonce *int64)

func (*Cache) BalanceAt

func (b *Cache) BalanceAt(ctx context.Context, client Reader, account common.Address, blockNumber *big.Int) (*big.Int, error)

func (*Cache) Cache

func (b *Cache) Cache() CacheIface

func (*Cache) Clear

func (b *Cache) Clear()

func (*Cache) GetBalance

func (b *Cache) GetBalance(account common.Address, chainID uint64, blockNumber *big.Int) *big.Int

func (*Cache) GetNonce

func (b *Cache) GetNonce(account common.Address, chainID uint64, blockNumber *big.Int) *int64

func (*Cache) NonceAt

func (b *Cache) NonceAt(ctx context.Context, client Reader, account common.Address, blockNumber *big.Int) (*int64, error)

type CacheIface

type CacheIface interface {
	GetBalance(account common.Address, chainID uint64, blockNumber *big.Int) *big.Int
	GetNonce(account common.Address, chainID uint64, blockNumber *big.Int) *int64
	AddBalance(account common.Address, chainID uint64, blockNumber *big.Int, balance *big.Int)
	AddNonce(account common.Address, chainID uint64, blockNumber *big.Int, nonce *int64)
	Clear()
}

Interface for cache of balances.

type Cacher

type Cacher interface {
	BalanceAt(ctx context.Context, client Reader, account common.Address, blockNumber *big.Int) (*big.Int, error)
	NonceAt(ctx context.Context, client Reader, account common.Address, blockNumber *big.Int) (*int64, error)
	Clear()
	Cache() CacheIface
}

Cacher interface for caching balance to BalanceCache. Requires BalanceReader to fetch balance.

type Reader

type Reader interface {
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	FullTransactionByBlockNumberAndIndex(ctx context.Context, blockNumber *big.Int, index uint) (*chain.FullTransaction, error)
	NetworkID() uint64
}

Reader interface for reading balance at a specified address.

Jump to

Keyboard shortcuts

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