rpc

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GWEI = int64(1000000000)
)

Functions

func AllEvents

func AllEvents() (map[[32]byte]abi.Event, error)

this is helpful for debugging, lets you quickly find the type of each event

func PrepareContractTxn

func PrepareContractTxn(ctx context.Context, proxy db.DataServerProxy, ctxName string, callback berryCommon.TransactionGeneratorFN) error

Types

type ABICodec

type ABICodec struct {
	Events map[string]*abi.Event
	// contains filtered or unexported fields
}

ABICodec holds abi definitions for encoding/decoding contract methods and events

func BuildCodec

func BuildCodec() (*ABICodec, error)

BuildCodec constructs a merged abi structure representing all methods/events for Berry contracts. This is primarily used for mock encoding/decoding parameters but could also be used for manual RPC operations that do not rely on geth's contract impl

type CurrentChallenge

type CurrentChallenge struct {
	ChallengeHash [32]byte
	RequestID     *big.Int
	Difficulty    *big.Int
	QueryString   string
	Granularity   *big.Int
	Tip           *big.Int
}

CurrentChallenge holds details about the current mining challenge

type ETHClient

type ETHClient interface {

	//close the client
	Close()

	// CodeAt returns the code of the given account. This is needed to differentiate
	// between contract internal errors and the local chain being out of sync.
	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

	// ContractCall executes an Ethereum contract call with the specified data as the
	// input.
	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
	NonceAt(ctx context.Context, address common.Address) (uint64, error)
	PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)

	// PendingCodeAt returns the code of the given account in the pending state.
	PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

	//PendingNonceAt gets the given address's nonce for submitting transactions
	PendingNonceAt(ctx context.Context, address common.Address) (uint64, error)
	EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)
	SuggestGasPrice(ctx context.Context) (*big.Int, error)

	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
	BalanceAt(ctx context.Context, address common.Address, block *big.Int) (*big.Int, error)
	SendTransaction(ctx context.Context, tx *types.Transaction) error
	IsSyncing(ctx context.Context) (bool, error)
	NetworkID(ctx context.Context) (*big.Int, error)
	HeaderByNumber(ctx context.Context, num *big.Int) (*types.Header, error)
}

ETHClient is the main abstraction interface for client operations

func NewClient

func NewClient(url string) (ETHClient, error)

NewClient creates a new client instance

func NewMockClient

func NewMockClient() ETHClient

NewMockClient returns instance of mock client

func NewMockClientWithValues

func NewMockClientWithValues(opts *MockOptions) ETHClient

NewMockClientWithValues creates a mock client with default values to return for calls

type MockOptions

type MockOptions struct {
	ETHBalance       *big.Int
	MiningStatus     bool
	Nonce            uint64
	GasPrice         *big.Int
	TokenBalance     *big.Int
	Top50Requests    []*big.Int
	CurrentChallenge *CurrentChallenge
	DisputeStatus    *big.Int
	QueryMetadata    map[uint]*MockQueryMeta
}

MockOptions are config options for the mock client

type MockQueryMeta

type MockQueryMeta struct {
	QueryString string
	Granularity int
}

MockQueryMeta is hardcoded query metadata to use for testing

Jump to

Keyboard shortcuts

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