ethereum

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BootstrappedEthereumClient string = "BootstrappedEthereumClient"

BootstrappedEthereumClient is a key to mapped client in bootstrap context.

Variables

This section is empty.

Functions

func DefaultWaitForTransactionMiningContext

func DefaultWaitForTransactionMiningContext(d time.Duration) (ctx context.Context, cancelFunc context.CancelFunc)

DefaultWaitForTransactionMiningContext returns context with timeout for write operations

func SetClient

func SetClient(client Client)

SetClient sets the Client Note that this is a singleton and is the same connection for the whole application.

Types

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(context map[string]interface{}) error

Bootstrap initialises ethereum client.

type Client

type Client interface {

	// GetEthClient returns the ethereum client
	GetEthClient() *ethclient.Client

	// GetNodeURL returns the node url
	GetNodeURL() *url.URL

	// GetTxOpts returns a cached options if available else creates and returns new options
	GetTxOpts(accountName string) (*bind.TransactOpts, error)

	// SubmitTransactionWithRetries submits transaction to the ethereum chain
	// Blocking Function that sends transaction using reflection wrapped in a retrial block. It is based on the transactionUnderpriced error,
	// meaning that a transaction is being attempted to run twice, and the logic is to override the existing one. As we have constant
	// gas prices that means that a concurrent transaction race condition event has happened.
	// - contractMethod: Contract Method that implements GenericEthereumAsset (usually autogenerated binding from abi)
	// - params: Arbitrary number of parameters that are passed to the function fname call
	// Note: contractMethod must always return "*types.Transaction, error"
	SubmitTransactionWithRetries(contractMethod interface{}, opts *bind.TransactOpts, params ...interface{}) (tx *types.Transaction, err error)

	// GetGethCallOpts returns the Call options with default
	GetGethCallOpts() (*bind.CallOpts, context.CancelFunc)
}

Client can be implemented by any chain client

func GetClient

func GetClient() Client

GetClient returns the current Client

func NewGethClient

func NewGethClient(config Config) (Client, error)

NewGethClient returns an gethClient which implements Client

type Config

type Config interface {
	GetEthereumGasPrice() *big.Int
	GetEthereumGasLimit() uint64
	GetEthereumNodeURL() string
	GetEthereumAccount(accountName string) (account *config.AccountConfig, err error)
	GetEthereumIntervalRetry() time.Duration
	GetEthereumMaxRetries() int
	GetTxPoolAccessEnabled() bool
	GetEthereumContextReadWaitTimeout() time.Duration
}

Config defines functions to get ethereum details

Jump to

Keyboard shortcuts

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