ethbalance

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address added in v0.0.5

type Address = string

Address : wrapper type for an ETH address

type BalanceRequest added in v0.0.5

type BalanceRequest struct {
	Block   BlockNumber
	Address Address
	Source  Source
}

BalanceRequest : a unit of work

type BlockNumber added in v0.0.5

type BlockNumber = uint64

BlockNumber : wrapper type for a block numnber

type Bookkeeper

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

Bookkeeper wraps the operations

func New

func New(eth ethrpc.ETHInterface, retries uint) *Bookkeeper

New returns a new Bookkeeper struct

func (*Bookkeeper) GetIntBalanceResults added in v0.0.5

func (b *Bookkeeper) GetIntBalanceResults(requests []*BalanceRequest) ([]*IntBalanceResponse, error)

GetIntBalanceResults returns an array of *big.Int balance results for the provided requests

Example
r, err := ethrpc.NewWithDefaults("wss://mainnet.infura.io/ws")
if err != nil {
	fmt.Println(err)
	return
}

b := New(r, 10)
results, err := b.GetIntBalanceResults(balanceRequests())

if err != nil {
	fmt.Println(err)
	return
}

for _, res := range results {
	fmt.Printf("%s[%s]: %s\n", res.Request.Address, res.Request.Source, res.Balance)
}
// Example output:
// 0xa838e871a02c6d883bf004352fc7dac8f781fed6[0xd26114cd6EE289AccF82350c8d8487fedB8A0C07]: 409757565152676909
// 0xa838e871a02c6d883bf004352fc7dac8f781fed6[0x8aa33a7899fcc8ea5fbe6a608a109c3893a1b8b2]: 3600000000000000000000
// 0xa838e871a02c6d883bf004352fc7dac8f781fed6[0x0f5d2fb29fb7d3cfee444a200298f468908cc942]: 7041922408306145321820
// 0xa838e871a02c6d883bf004352fc7dac8f781fed6[eth]: 1000670436501076869
// 0xa838e871a02c6d883bf004352fc7dac8f781fed6[0xBEB9eF514a379B997e0798FDcC901Ee474B6D9A1]: 33780620000000000000

func (*Bookkeeper) GetIntBalanceSheet added in v0.0.5

func (b *Bookkeeper) GetIntBalanceSheet(requests []*BalanceRequest) (IntBalanceSheet, error)

GetIntBalanceSheet takes a list of balance requests and returns a tree like structure containing all int balances

func (*Bookkeeper) GetRawBalanceResults added in v0.0.5

func (b *Bookkeeper) GetRawBalanceResults(requests []*BalanceRequest) ([]*RawBalanceResponse, error)

GetRawBalanceResults returns an array of hex string balance results for the provided requests

func (*Bookkeeper) GetRawBalanceSheet added in v0.0.5

func (b *Bookkeeper) GetRawBalanceSheet(requests []*BalanceRequest) (RawBalanceSheet, error)

GetRawBalanceSheet takes a list of balance requests and returns a tree like structure containing all hex string balances

type CollectBalancesError added in v0.0.5

type CollectBalancesError struct {
	Errors []*RequestError
}

CollectBalancesError wraps errors returned from the RPC requests

func (CollectBalancesError) Error added in v0.0.5

func (cbe CollectBalancesError) Error() string

Error message aggregates all unique errors

type IntBalanceResponse added in v0.0.5

type IntBalanceResponse struct {
	Request *BalanceRequest
	Balance *big.Int
}

IntBalanceResponse : the converted response associated with a balance request

type IntBalanceSheet added in v0.0.5

type IntBalanceSheet = map[BlockNumber]map[Address]map[Source]*big.Int

IntBalanceSheet : the tree-like structure with all balances converted to big.Int

type RawBalanceResponse added in v0.0.5

type RawBalanceResponse struct {
	Request *BalanceRequest
	Balance string
}

RawBalanceResponse : the raw response associated with a balance request

type RawBalanceSheet added in v0.0.5

type RawBalanceSheet = map[BlockNumber]map[Address]map[Source]string

RawBalanceSheet : the tree-like structure representing all un-parsed balances

type RequestError added in v0.0.5

type RequestError struct {
	Request *BalanceRequest
	Err     error
}

RequestError wraps a request with the error received

type Source added in v0.0.5

type Source string

Source : either "ETH" or a token address

const (
	// ETH : Ethereum source
	ETH Source = "ETH"
)

Jump to

Keyboard shortcuts

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