librelay

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const TxReceiptTimeout = 60 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditRelaysRequest

type AuditRelaysRequest struct {
	SignedTx string
}

type GetEthAddrResponse

type GetEthAddrResponse struct {
	RelayServerAddress common.Address
	MinGasPrice        big.Int
	Ready              bool
	Version            string
}

type IClient

type IClient interface {
	bind.ContractBackend
	ethereum.TransactionReader

	NetworkID(ctx context.Context) (*big.Int, error)

	//From: ChainReader
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

	// From:  ChainStateReader, minus CodeAt
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
}

func NewEthClient

func NewEthClient(EthereumNodeURL string, defaultGasPrice int64) (IClient, error)

type IRelay

type IRelay interface {
	Balance() (balance *big.Int, err error)

	GasPrice() big.Int

	RefreshGasPrice() (err error)

	RegisterRelay() (err error)

	IsStaked() (staked bool, err error)

	IsUnstaked() (removed bool, err error)

	BlockCountSinceRegistration() (when uint64, err error)

	GetRegistrationBlockRate() (rate uint64)

	IsRemoved() (removed bool, err error)

	SendBalanceToOwner() (err error)

	CreateRelayTransaction(request RelayTransactionRequest) (signedTx *types.Transaction, err error)

	Address() (relayAddress common.Address)

	HubAddress() common.Address

	GetUrl() string

	GetPort() string

	UpdateUnconfirmedTransactions() (newTx *types.Transaction, err error)

	Close() (err error)
	// contains filtered or unexported methods
}

type RelayParams

type RelayParams struct {
	RelayServer
	DBFile string
}

func (*RelayParams) Dump added in v0.4.5

func (relayParams *RelayParams) Dump()

type RelayServer

type RelayServer struct {
	OwnerAddress          common.Address
	Fee                   *big.Int
	Url                   string
	Port                  string
	RelayHubAddress       common.Address
	DefaultGasPrice       int64
	GasPricePercent       *big.Int
	PrivateKey            *ecdsa.PrivateKey
	RegistrationBlockRate uint64
	EthereumNodeURL       string

	Client IClient

	TxStore txstore.ITxStore

	DevMode bool
	// contains filtered or unexported fields
}

func NewRelayServer

func NewRelayServer(
	OwnerAddress common.Address,
	Fee *big.Int,
	Url string,
	Port string,
	RelayHubAddress common.Address,
	DefaultGasPrice int64,
	GasPricePercent *big.Int,
	PrivateKey *ecdsa.PrivateKey,
	RegistrationBlockRate uint64,
	EthereumNodeURL string,
	Client IClient,
	TxStore txstore.ITxStore,
	clk clock.Clock,
	DevMode bool) (*RelayServer, error)

func (*RelayServer) Address

func (relay *RelayServer) Address() (relayAddress common.Address)

func (*RelayServer) Balance

func (relay *RelayServer) Balance() (balance *big.Int, err error)

func (*RelayServer) BlockCountSinceRegistration added in v0.4.5

func (relay *RelayServer) BlockCountSinceRegistration() (count uint64, err error)

func (*RelayServer) ChainID

func (relay *RelayServer) ChainID() (chainID *big.Int, err error)

func (*RelayServer) Close

func (relay *RelayServer) Close() (err error)

func (*RelayServer) CreateRelayTransaction

func (relay *RelayServer) CreateRelayTransaction(request RelayTransactionRequest) (signedTx *types.Transaction, err error)

func (*RelayServer) GasPrice

func (relay *RelayServer) GasPrice() big.Int

func (*RelayServer) GetPort

func (relay *RelayServer) GetPort() string

func (*RelayServer) GetRegistrationBlockRate added in v0.4.5

func (relay *RelayServer) GetRegistrationBlockRate() uint64

func (*RelayServer) GetUrl

func (relay *RelayServer) GetUrl() string

func (*RelayServer) HubAddress

func (relay *RelayServer) HubAddress() common.Address

func (*RelayServer) IsRemoved

func (relay *RelayServer) IsRemoved() (removed bool, err error)

func (*RelayServer) IsStaked

func (relay *RelayServer) IsStaked() (staked bool, err error)

func (*RelayServer) IsUnstaked

func (relay *RelayServer) IsUnstaked() (removed bool, err error)

func (*RelayServer) RefreshGasPrice

func (relay *RelayServer) RefreshGasPrice() (err error)

func (*RelayServer) RegisterRelay

func (relay *RelayServer) RegisterRelay() (err error)

func (*RelayServer) RemoveRelay

func (relay *RelayServer) RemoveRelay(ownerKey *ecdsa.PrivateKey) (err error)

func (*RelayServer) SendBalanceToOwner

func (relay *RelayServer) SendBalanceToOwner() (err error)

func (*RelayServer) UpdateUnconfirmedTransactions

func (relay *RelayServer) UpdateUnconfirmedTransactions() (newTx *types.Transaction, err error)

type RelayTransactionRequest

type RelayTransactionRequest struct {
	EncodedFunction string
	ApprovalData    []byte
	Signature       []byte
	From            common.Address
	To              common.Address
	GasPrice        big.Int
	GasLimit        big.Int
	RecipientNonce  big.Int
	RelayMaxNonce   big.Int
	RelayFee        big.Int
	RelayHubAddress common.Address
}

type RelayTransactionResponse

type RelayTransactionResponse struct {
	SignedTx   *types.Transaction
	RawTxBytes []byte
}

func (*RelayTransactionResponse) MarshalJSON

func (response *RelayTransactionResponse) MarshalJSON() ([]byte, error)

type SetHubRequest

type SetHubRequest struct {
	RelayHubAddress common.Address
}

type TbkClient

type TbkClient struct {
	*ethclient.Client

	DefaultGasPrice int64
}

We hook ethclient since EstimateGas returns inaccurate estimation, due to state differences * of executing a tx locally through eth_call vs on the blockchain ( msg.sender.balance for example)

func (*TbkClient) EstimateGas

func (tbkClient *TbkClient) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

func (*TbkClient) SuggestGasPrice

func (tbkClient *TbkClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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