Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
GWEI = int64(1000000000)
)
Functions ¶
func PrepareContractTxn ¶
func PrepareContractTxn(ctx context.Context, proxy db.DataServerProxy, ctxName string, callback berryCommon.TransactionGeneratorFN) error
Types ¶
type ABICodec ¶
ABICodec holds abi definitions for encoding/decoding contract methods and events
func BuildCodec ¶
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 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 ¶
MockQueryMeta is hardcoded query metadata to use for testing
Click to show internal directories.
Click to hide internal directories.