api

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMetrics

func InitMetrics()

InitMetrics initialise metrics

Types

type BlockErrorPair

type BlockErrorPair struct {
	Height uint64
	Block  structs.Block
	Err    error
}

BlockErrorPair to wrap error response

type BlocksMap

type BlocksMap struct {
	sync.Mutex
	Blocks map[uint64]structs.Block
	NumTxs uint64
}

BlocksMap map of blocks to control block map with extra summary of number of transactions

type Client

type Client struct {
	Sbc *SimpleBlockCache
	// contains filtered or unexported fields
}

Client

func NewClient

func NewClient(logger *zap.Logger, cli *grpc.ClientConn, cfg *ClientConfig) *Client

NewClient returns a new client for a given endpoint

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, params structs.HeightHash) (block structs.Block, er error)

GetBlock fetches most recent block from chain

func (Client) GetBlockAsync

func (c Client) GetBlockAsync(ctx context.Context, in chan uint64, out chan<- BlockErrorPair)

func (Client) GetBlocksMeta

func (c Client) GetBlocksMeta(ctx context.Context, params structs.HeightRange, blocks *BlocksMap) error

func (*Client) GetRewardBalances added in v0.3.1

func (c *Client) GetRewardBalances(ctx context.Context, pparams []structs.HeightAccount) (resps map[uint64]structs.GetRewardResponse, err error)

GetReward fetches total rewards for delegator account

func (*Client) GetTx added in v0.3.1

func (c *Client) GetTx(ctx context.Context, qstring []string) (txs []*tx.GetTxsEventResponse, err error)

SearchTx is making search api call

func (*Client) SearchTx

func (c *Client) SearchTx(ctx context.Context, r structs.HeightHash, block structs.Block, perPage uint64) (txs []structs.Transaction, err error)

SearchTx is making search api call

type ClientConfig added in v0.1.5

type ClientConfig struct {
	ReqPerSecond        int
	TimeoutBlockCall    time.Duration
	TimeoutSearchTxCall time.Duration
}

type SimpleBlockCache

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

SimpleBlockCache simple in memory block cache to store latest blocks

func NewSimpleBlockCache

func NewSimpleBlockCache(cap int) *SimpleBlockCache

NewSimpleBlockCache a SimpleBlockCache constructor

func (*SimpleBlockCache) Add

func (sbc *SimpleBlockCache) Add(bl structs.Block)

Add blocks to the cache (thread safe)

func (*SimpleBlockCache) Get

func (sbc *SimpleBlockCache) Get(height uint64) (bl structs.Block, ok bool)

Get and check block of given height (thread safe)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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