Documentation ¶
Index ¶
- Constants
- func IsETH(token string) bool
- func LatestAggregatorContracts() []common.Address
- type BlockMetaAccessor
- type Client
- func (c *Client) AddSignedTxItem(hash string, height int64, vaultPubKey string) error
- func (c *Client) BroadcastTx(txOutItem stypes.TxOutItem, hexTx []byte) (string, error)
- func (c *Client) ConfirmationCountReady(txIn stypes.TxIn) bool
- func (c *Client) GetAccount(pk common.PubKey, height *big.Int) (common.Account, error)
- func (c *Client) GetAccountByAddress(address string, height *big.Int) (common.Account, error)
- func (c *Client) GetAddress(poolPubKey common.PubKey) string
- func (c *Client) GetBalance(addr, token string, height *big.Int) (*big.Int, error)
- func (c *Client) GetBalances(addr string, height *big.Int) (common.Coins, error)
- func (c *Client) GetChain() common.Chain
- func (c *Client) GetConfig() config.BifrostChainConfiguration
- func (c *Client) GetConfirmationCount(txIn stypes.TxIn) int64
- func (c *Client) GetGasFee(gas uint64) common.Gas
- func (c *Client) GetGasPrice() *big.Int
- func (c *Client) GetHeight() (int64, error)
- func (c *Client) GetNonce(addr string) (uint64, error)
- func (c *Client) IsBlockScannerHealthy() bool
- func (c *Client) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)
- func (c *Client) ReportSolvency(ethBlockHeight int64) error
- func (c *Client) ShouldReportSolvency(height int64) bool
- func (c *Client) SignTx(tx stypes.TxOutItem, height int64) ([]byte, []byte, *stypes.TxInItem, error)
- func (c *Client) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, ...)
- func (c *Client) Stop()
- type DDChainRouterTransferOutAndCall
- type ETHScanner
- type LevelDBBlockMetaAccessor
- func (t *LevelDBBlockMetaAccessor) AddSignedTxItem(item SignedTxItem) error
- func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*types.BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*types.BlockMeta, error)
- func (t *LevelDBBlockMetaAccessor) GetSignedTxItems() ([]SignedTxItem, error)
- func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
- func (t *LevelDBBlockMetaAccessor) RemoveSignedTxItem(hash string) error
- func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *types.BlockMeta) error
- type LevelDBTokenMeta
- type RouterCoin
- type SignedTxItem
- type SmartContractLogParser
- type SolvencyReporter
Constants ¶
const ( BlockCacheSize = 6000 MaxContractGas = 80000 )
const ( PrefixBlockMeta = `eth-blockmeta-` PrefixSignedTxItem = `signed-txitem-` )
PrefixTxStorage declares prefix to use in leveldb to avoid conflicts
const TxWaitBlocks = 150
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockMetaAccessor ¶
type BlockMetaAccessor interface { GetBlockMetas() ([]*types.BlockMeta, error) GetBlockMeta(height int64) (*types.BlockMeta, error) SaveBlockMeta(height int64, block *types.BlockMeta) error PruneBlockMeta(height int64) error AddSignedTxItem(item SignedTxItem) error RemoveSignedTxItem(hash string) error GetSignedTxItems() ([]SignedTxItem, error) }
BlockMetaAccessor define methods need to access block meta storage
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a structure to sign and broadcast tx to Ethereum chain used by signer mostly
func NewClient ¶
func NewClient(ddKeys *ddclient.Keys, cfg config.BifrostChainConfiguration, server *tssp.TssServer, bridge ddclient.DdchainBridge, m *metrics.Metrics, pubkeyMgr pubkeymanager.PubKeyValidator, poolMgr ddclient.PoolManager, ) (*Client, error)
NewClient create new instance of Ethereum client
func (*Client) AddSignedTxItem ¶
AddSignedTxItem add the transaction to key value store
func (*Client) BroadcastTx ¶
BroadcastTx decodes tx using rlp and broadcasts too Ethereum chain
func (*Client) ConfirmationCountReady ¶
ConfirmationCountReady check whether the given txIn is ready to be send to DDChain
func (*Client) GetAccount ¶
GetAccount gets account by address in eth client
func (*Client) GetAccountByAddress ¶
GetAccountByAddress return account information
func (*Client) GetAddress ¶
GetAddress return current signer address, it will be bech32 encoded address
func (*Client) GetBalance ¶
GetBalance call smart contract to find out the balance of the given address and token
func (*Client) GetBalances ¶
GetBalances gets all the balances of the given address
func (*Client) GetConfig ¶
func (c *Client) GetConfig() config.BifrostChainConfiguration
GetConfig return the configurations used by ETH chain
func (*Client) GetConfirmationCount ¶
GetConfirmationCount decide the given txIn how many confirmation it requires
func (*Client) GetGasPrice ¶
GetGasPrice gets gas price from eth scanner
func (*Client) IsBlockScannerHealthy ¶
func (*Client) OnObservedTxIn ¶
OnObservedTxIn gets called from observer when we have a valid observation
func (*Client) ReportSolvency ¶
func (*Client) ShouldReportSolvency ¶
ShouldReportSolvency with given block height , should chain client report Solvency to DDNode?
func (*Client) SignTx ¶
func (c *Client) SignTx(tx stypes.TxOutItem, height int64) ([]byte, []byte, *stypes.TxInItem, error)
SignTx sign the the given TxArrayItem
type DDChainRouterTransferOutAndCall ¶ added in v0.2.0
type DDChainRouterTransferOutAndCall struct { Vault ecommon.Address Target ecommon.Address Amount *big.Int FinalAsset ecommon.Address To ecommon.Address AmountOutMin *big.Int Memo string }
DDChainRouterTransferOutAndCall represents a TransferOutAndCall event raised by the DDChainRouter contract.
type ETHScanner ¶
type ETHScanner struct {
// contains filtered or unexported fields
}
ETHScanner is a scanner that understand how to interact with ETH chain ,and scan block , parse smart contract etc
func NewETHScanner ¶
func NewETHScanner(cfg config.BifrostBlockScannerConfiguration, storage blockscanner.ScannerStorage, chainID *big.Int, client *ethclient.Client, bridge ddclient.DdchainBridge, m *metrics.Metrics, pubkeyMgr pubkeymanager.PubKeyValidator, solvencyReporter SolvencyReporter, signerCacheManager *signercache.CacheManager, ) (*ETHScanner, error)
NewETHScanner create a new instance of ETHScanner
func (*ETHScanner) FetchMemPool ¶
func (e *ETHScanner) FetchMemPool(_ int64) (stypes.TxIn, error)
FetchMemPool get tx from mempool
func (*ETHScanner) FetchTxs ¶
func (e *ETHScanner) FetchTxs(height, chainHeight int64) (stypes.TxIn, error)
FetchTxs query the ETH chain to get txs in the given block height
func (*ETHScanner) GetGasPrice ¶
func (e *ETHScanner) GetGasPrice() *big.Int
GetGasPrice returns current gas price
func (*ETHScanner) GetHeight ¶
func (e *ETHScanner) GetHeight() (int64, error)
GetHeight return latest block height
type LevelDBBlockMetaAccessor ¶
type LevelDBBlockMetaAccessor struct {
// contains filtered or unexported fields
}
LevelDBBlockMetaAccessor struct
func NewLevelDBBlockMetaAccessor ¶
func NewLevelDBBlockMetaAccessor(db *leveldb.DB) (*LevelDBBlockMetaAccessor, error)
NewLevelDBBlockMetaAccessor creates a new level db backed BlockMeta accessor
func (*LevelDBBlockMetaAccessor) AddSignedTxItem ¶
func (t *LevelDBBlockMetaAccessor) AddSignedTxItem(item SignedTxItem) error
AddSignedTxItem add a signed tx item to key value store
func (*LevelDBBlockMetaAccessor) GetBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMeta(height int64) (*types.BlockMeta, error)
GetBlockMeta at given block height , when the requested block meta doesn't exist , it will return nil , thus caller need to double check it
func (*LevelDBBlockMetaAccessor) GetBlockMetas ¶
func (t *LevelDBBlockMetaAccessor) GetBlockMetas() ([]*types.BlockMeta, error)
GetBlockMetas returns all the block metas in storage The chain client will Prune block metas every time it finished scan a block , so at maximum it will keep BlockCacheSize blocks thus it should not grow out of control
func (*LevelDBBlockMetaAccessor) GetSignedTxItems ¶
func (t *LevelDBBlockMetaAccessor) GetSignedTxItems() ([]SignedTxItem, error)
GetSignedTxItems get all the signed tx items that in the key value store
func (*LevelDBBlockMetaAccessor) PruneBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) PruneBlockMeta(height int64) error
PruneBlockMeta remove all block meta that is older than the given block height with exception, if there are unspent transaction output in it , then the block meta will not be removed
func (*LevelDBBlockMetaAccessor) RemoveSignedTxItem ¶
func (t *LevelDBBlockMetaAccessor) RemoveSignedTxItem(hash string) error
RemoveSignedTxItem remove a signed item from key value store
func (*LevelDBBlockMetaAccessor) SaveBlockMeta ¶
func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *types.BlockMeta) error
SaveBlockMeta persistent the given BlockMeta into storage
type LevelDBTokenMeta ¶
type LevelDBTokenMeta struct {
// contains filtered or unexported fields
}
LevelDBTokenMeta struct
func NewLevelDBTokenMeta ¶
func NewLevelDBTokenMeta(db *leveldb.DB) (*LevelDBTokenMeta, error)
NewLevelDBTokenMeta creates a new level db backed TokenMeta
func (*LevelDBTokenMeta) GetTokenMeta ¶
func (t *LevelDBTokenMeta) GetTokenMeta(address string) (types.TokenMeta, error)
GetTokenMeta for given token address
func (*LevelDBTokenMeta) GetTokens ¶
func (t *LevelDBTokenMeta) GetTokens() ([]*types.TokenMeta, error)
GetTokens returns all the token metas in storage
func (*LevelDBTokenMeta) SaveTokenMeta ¶
func (t *LevelDBTokenMeta) SaveTokenMeta(symbol, address string, decimals uint64) error
SaveTokenMeta persistent the given TokenMeta into storage
type RouterCoin ¶
RouterCoin represent the coins transfer between vault
type SignedTxItem ¶
type SmartContractLogParser ¶
type SmartContractLogParser struct {
// contains filtered or unexported fields
}
func NewSmartContractLogParser ¶
func NewSmartContractLogParser(validator contractAddressValidator, resolver assetResolver, decimalResolver tokenDecimalResolver, amtConverter amountConverter, vaultABI *abi.ABI, ) SmartContractLogParser
func (*SmartContractLogParser) ParseTransferOutAndCall ¶
func (scp *SmartContractLogParser) ParseTransferOutAndCall(log etypes.Log) (*DDChainRouterTransferOutAndCall, error)
ParseTransferOutAndCall is a log parse operation binding the contract event 0xbda904e26adea40cc083dc36e80fde1641dfdd8b9a035c44022a43e713f73d36.
type SolvencyReporter ¶
SolvencyReporter is to report solvency info to DDNode