Documentation
¶
Index ¶
- type Address
- type BalanceRequest
- type BlockNumber
- type Bookkeeper
- func (b *Bookkeeper) GetIntBalanceResults(requests []*BalanceRequest) ([]*IntBalanceResponse, error)
- func (b *Bookkeeper) GetIntBalanceSheet(requests []*BalanceRequest) (IntBalanceSheet, error)
- func (b *Bookkeeper) GetRawBalanceResults(requests []*BalanceRequest) ([]*RawBalanceResponse, error)
- func (b *Bookkeeper) GetRawBalanceSheet(requests []*BalanceRequest) (RawBalanceSheet, error)
- type CollectBalancesError
- type IntBalanceResponse
- type IntBalanceSheet
- type RawBalanceResponse
- type RawBalanceSheet
- type RequestError
- type Source
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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