Documentation
¶
Index ¶
- Constants
- Variables
- type Bridge
- type LightClient
- func (lc *LightClient) AccountAddress() (common.Address, error)
- func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
- func (lc *LightClient) Close() error
- func (lc *LightClient) FetchTransaction(ctx context.Context, blockHash common.Hash, txHash common.Hash) (*types.Transaction, uint64, error)
- func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
- func (lc *LightClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- type LightClientConfig
Constants ¶
const ( // TFTBlockDelay is the amount of blocks to wait before // pushing tft transactions to the ethereum contract TFTBlockDelay = 6 // EthBlockDelay is the amount of blocks to wait before // pushing eth transaction to the tfchain network EthBlockDelay = 30 )
Variables ¶
var ( // ErrNoAccountLoaded is an error returned for all Light Client methods // that require an account and for which no account is loaded. ErrNoAccountLoaded = errors.New("no account was loaded into the light client") )
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge is a high lvl structure which listens on contract events and bridge-related tfchain transactions, and handles them
func NewBridge ¶
func NewBridge(cs modules.ConsensusSet, txdb *persist.TransactionDB, tp modules.TransactionPool, ethPort uint16, accountJSON, accountPass string, ethNetworkName string, contractAddress string, datadir string, bcInfo types.BlockchainInfo, chainCts types.ChainConstants, cancel <-chan struct{}) (*Bridge, error)
NewBridge creates a new Bridge.
func (*Bridge) ProcessConsensusChange ¶
func (bridge *Bridge) ProcessConsensusChange(css modules.ConsensusChange)
ProcessConsensusChange implements modules.ConsensusSetSubscriber, used to apply/revert blocks.
type LightClient ¶
type LightClient struct {
*ethclient.Client // Client connection to the Ethereum chain
// contains filtered or unexported fields
}
LightClient creates a light client that can be used to interact with the Ethereum network, for ERC20 purposes. By default it is read-only, in order to also write to the network, you'll need load an account using the LoadAccount method.
func NewLightClient ¶
func NewLightClient(lccfg LightClientConfig, cancel <-chan struct{}) (*LightClient, error)
NewLightClient creates a new light client that can be used to interact with the ETH network. See `LightClient` for more information.
func (*LightClient) AccountAddress ¶
func (lc *LightClient) AccountAddress() (common.Address, error)
AccountAddress returns the address of the loaded account, returning an error only if no account was loaded.
func (*LightClient) AccountBalanceAt ¶
func (lc *LightClient) AccountBalanceAt(ctx context.Context, blockNumber *big.Int) (*big.Int, error)
AccountBalanceAt returns the balance for the account at the given block height.
func (*LightClient) Close ¶
func (lc *LightClient) Close() error
Close terminates the Ethereum connection and tears down the stack.
func (*LightClient) FetchTransaction ¶
func (lc *LightClient) FetchTransaction(ctx context.Context, blockHash common.Hash, txHash common.Hash) (*types.Transaction, uint64, error)
FetchTransaction fetches a transaction from a remote peer using its block hash and tx index (within that block). Together with a found transactions it also returns the confirmations available for that Tx.
func (*LightClient) LoadAccount ¶
func (lc *LightClient) LoadAccount(accountJSON, accountPass string) error
LoadAccount loads an account into this light client, allowing writeable operations using the loaded account. An error is returned in case no account could be loaded.
func (*LightClient) SignTx ¶
func (lc *LightClient) SignTx(tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
SignTx signs a given traction with the loaded account, returning the signed transaction and no error on success.