cli

package
v0.0.0-...-2804839 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	ParentSlot uint64
	BlockTime  uint64
	Blockhash  string

	Transactions []Tx
}

Parsed block

type BlockLoader

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

BlockLoader batches and caches requests

func NewBlockLoader

func NewBlockLoader(config BlockLoaderConfig) *BlockLoader

NewBlockLoader creates a new BlockLoader given a fetch, wait, and maxBatch

func (*BlockLoader) Clear

func (l *BlockLoader) Clear(key uint64)

Clear the value at key from the cache, if it exists

func (*BlockLoader) Load

func (l *BlockLoader) Load(key uint64) (Block, error)

Load a Block by key, batching and caching will be applied automatically

func (*BlockLoader) LoadAll

func (l *BlockLoader) LoadAll(keys []uint64) ([]Block, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*BlockLoader) LoadAllThunk

func (l *BlockLoader) LoadAllThunk(keys []uint64) func() ([]Block, []error)

LoadAllThunk returns a function that when called will block waiting for a Blocks. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*BlockLoader) LoadThunk

func (l *BlockLoader) LoadThunk(key uint64) func() (Block, error)

LoadThunk returns a function that when called will block waiting for a Block. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.

func (*BlockLoader) Prime

func (l *BlockLoader) Prime(key uint64, value Block) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type BlockLoaderConfig

type BlockLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uint64) ([]Block, []error)

	// Wait is how long wait before sending a batch
	Wait time.Duration

	// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
	MaxBatch int
}

BlockLoaderConfig captures the config to create a new BlockLoader

type BlockRawTransaction

type BlockRawTransaction struct {
	Meta        txMeta    `json:"meta"`
	Transaction [2]string `json:"transaction"`
	Version     any       `json:"version"`
}

func (BlockRawTransaction) MarshalEasyJSON

func (v BlockRawTransaction) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (BlockRawTransaction) MarshalJSON

func (v BlockRawTransaction) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*BlockRawTransaction) UnmarshalEasyJSON

func (v *BlockRawTransaction) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*BlockRawTransaction) UnmarshalJSON

func (v *BlockRawTransaction) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type RPC

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

func NewRpc

func NewRpc(l lgr.L, endpoint string) RPC

func (RPC) GetBlocks

func (r RPC) GetBlocks(ctx context.Context, retries uint, blocksIds ...uint64) ([]Block, []int, error)

GetBlocks will recursevily try to fetch specified block ids until 0 retries left todo use backoff

func (RPC) GetBlocksWithLimit

func (r RPC) GetBlocksWithLimit(ctx context.Context, from, limit uint64) ([]uint64, error)

func (RPC) GetLatestBlock

func (r RPC) GetLatestBlock(ctx context.Context) (uint64, error)

Retruns latest slot and total block count

func (RPC) MarshalEasyJSON

func (v RPC) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (RPC) MarshalJSON

func (v RPC) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*RPC) UnmarshalEasyJSON

func (v *RPC) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*RPC) UnmarshalJSON

func (v *RPC) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type TokenBalanceChange

type TokenBalanceChange struct {
	Delta       int64
	Decimals    uint8
	Owner, Mint common.PublicKey
}

type Tx

type Tx struct {
	TxHash     string
	Meta       TxMeta
	Insts      []types.Instruction
	InnerInsts map[int][]types.Instruction
}

Parsed tx

func TxFromBlockTransaction

func TxFromBlockTransaction(l lgr.L, blockTx BlockRawTransaction) (transaction Tx, include bool, err error)

TxFromBlockTransaction parses raw rpc transaction to appropriate form for parsing todo: exposed for tests. parsing can happen in different entity. fine for now

type TxMeta

type TxMeta struct {
	BalanceChanges      map[common.PublicKey]int64
	TokenBalanceChanges map[common.PublicKey]TokenBalanceChange
	Logs                []string
}

Jump to

Keyboard shortcuts

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