blockchain

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 20 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseBlockchain

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

func NewBaseBlockchain

func NewBaseBlockchain(
	rpcClient *rpc.Client,
	client *ethclient.Client,
	operators map[string]*Operator,
	broadcaster *Broadcaster,
	contractcaller *ContractCaller) *BaseBlockchain

func (*BaseBlockchain) BuildSendERC20Tx

func (b *BaseBlockchain) BuildSendERC20Tx(opts TxOpts, amount *big.Int, to ethereum.Address, tokenAddress ethereum.Address) (*types.Transaction, error)

func (*BaseBlockchain) BuildSendETHTx

func (b *BaseBlockchain) BuildSendETHTx(opts TxOpts, to ethereum.Address) (*types.Transaction, error)

func (*BaseBlockchain) BuildTx

func (b *BaseBlockchain) BuildTx(context context.Context, opts TxOpts, contract *Contract, method string, params ...interface{}) (*types.Transaction, error)

func (*BaseBlockchain) Call

func (b *BaseBlockchain) Call(timeOut time.Duration, opts CallOpts, contract *Contract, result interface{}, method string, params ...interface{}) error

func (*BaseBlockchain) CurrentBlock

func (b *BaseBlockchain) CurrentBlock() (uint64, error)

func (*BaseBlockchain) GetCallOpts

func (b *BaseBlockchain) GetCallOpts(block uint64) CallOpts

func (*BaseBlockchain) GetLogs

func (b *BaseBlockchain) GetLogs(param ether.FilterQuery) ([]types.Log, error)

func (*BaseBlockchain) GetMinedNonce

func (b *BaseBlockchain) GetMinedNonce(operator string) (uint64, error)

func (*BaseBlockchain) GetNextNonce

func (b *BaseBlockchain) GetNextNonce(operator string) (*big.Int, error)

func (*BaseBlockchain) GetTxOpts

func (b *BaseBlockchain) GetTxOpts(op string, nonce *big.Int, gasPrice *big.Int, value *big.Int) (TxOpts, error)

func (*BaseBlockchain) MustGetOperator

func (b *BaseBlockchain) MustGetOperator(name string) *Operator

MustGetOperator returns the operator if avail, panic if the operator can't be found

func (*BaseBlockchain) MustRegisterOperator

func (b *BaseBlockchain) MustRegisterOperator(name string, op *Operator)

func (*BaseBlockchain) OperatorAddresses

func (b *BaseBlockchain) OperatorAddresses() map[string]ethereum.Address

func (*BaseBlockchain) PackERC20Data

func (b *BaseBlockchain) PackERC20Data(method string, params ...interface{}) ([]byte, error)

func (*BaseBlockchain) RecommendedGasPriceFromNode

func (b *BaseBlockchain) RecommendedGasPriceFromNode() (*big.Int, error)

func (*BaseBlockchain) SignAndBroadcast

func (b *BaseBlockchain) SignAndBroadcast(tx *types.Transaction, from string) (*types.Transaction, error)

func (*BaseBlockchain) TransactionByHash

func (b *BaseBlockchain) TransactionByHash(ctx context.Context, hash ethereum.Hash) (tx *RPCTransaction, isPending bool, err error)

func (*BaseBlockchain) TxStatus

func (b *BaseBlockchain) TxStatus(hash ethereum.Hash) (string, uint64, error)

type Broadcaster

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

Broadcaster takes a signed tx and try to broadcast it to all nodes that it manages as fast as possible. It returns a map of failures and a bool indicating that the tx is broadcasted to at least 1 node

func NewBroadcaster

func NewBroadcaster(clients map[string]*ethclient.Client) *Broadcaster

func (Broadcaster) Broadcast

func (b Broadcaster) Broadcast(tx *types.Transaction) (map[string]error, bool)

type CallOpts

type CallOpts struct {
	Block *big.Int // Block number that the call is invoked at. Nil means calling in pending state
}

type Contract

type Contract struct {
	Address ethereum.Address
	ABI     abi.ABI
}

func NewContract

func NewContract(address ethereum.Address, abipath string) *Contract

type ContractCaller

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

func NewContractCaller

func NewContractCaller(clients []*common.EthClient) *ContractCaller

func (ContractCaller) CallContract

func (c ContractCaller) CallContract(msg ether.CallMsg, blockNo *big.Int, timeOut time.Duration) ([]byte, error)

type EthereumSigner

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

func NewEthereumSigner

func NewEthereumSigner(keyPath string, passphrase string) *EthereumSigner

func (EthereumSigner) GetAddress

func (es EthereumSigner) GetAddress() ethereum.Address

func (EthereumSigner) Sign

type NonceCorpus

type NonceCorpus interface {
	GetAddress() ethereum.Address
	GetNextNonce(ethclient *ethclient.Client) (*big.Int, error)
	MinedNonce(ethclient *ethclient.Client) (*big.Int, error)
}

NonceCorpus is the interface to keep track of transaction count of an ethereum account.

type Operator

type Operator struct {
	Address     ethereum.Address
	NonceCorpus NonceCorpus
	Signer      Signer
}

func NewOperator

func NewOperator(signer Signer, nonce NonceCorpus) *Operator

type RPCTransaction

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

func (*RPCTransaction) BlockNumber

func (tx *RPCTransaction) BlockNumber() *big.Int

func (*RPCTransaction) UnmarshalJSON

func (tx *RPCTransaction) UnmarshalJSON(msg []byte) error

type Signer

type Signer interface {
	GetAddress() ethereum.Address
	Sign(*types.Transaction) (*types.Transaction, error)
}

Signer contains method to sign a Ethereum transaction.

type TxOpts

type TxOpts struct {
	Operator *Operator // Ethereum account to send the transaction from
	Nonce    *big.Int  // Nonce to use for the transaction execution (nil = use pending state)

	Value    *big.Int // Funds to transfer along along the transaction (nil = 0 = no funds)
	GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
	GasLimit uint64   // Gas limit to set for the transaction execution (0 = estimate)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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