ethereum

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultObserverLevelDBFolder = `observer_data`
	BlockCacheSize               = 200
)
View Source
const (
	PrefixBlockMeta = `blockmeta-`
)

PrefixTxStorage declares prefix to use in leveldb to avoid conflicts

Variables

This section is empty.

Functions

This section is empty.

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
}

BlockMetaAccessor define methods need to access block meta storage

type BlockScanner

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

BlockScanner is to scan the blocks

func NewBlockScanner

NewBlockScanner create a new instance of BlockScan

func (*BlockScanner) FetchTxs

func (e *BlockScanner) FetchTxs(height int64) (stypes.TxIn, error)

func (*BlockScanner) GetGasPrice

func (e *BlockScanner) GetGasPrice() *big.Int

GetGasPrice returns current gas price

func (*BlockScanner) GetHeight

func (e *BlockScanner) GetHeight() (int64, error)

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(thorKeys *thorclient.Keys, cfg config.ChainConfiguration, server *tssp.TssServer, thorchainBridge *thorclient.ThorchainBridge, m *metrics.Metrics, keySignPartyMgr *thorclient.KeySignPartyMgr) (*Client, error)

NewClient create new instance of Ethereum client

func (*Client) BroadcastTx

func (c *Client) BroadcastTx(stx stypes.TxOutItem, hexTx []byte) error

BroadcastTx decodes tx using rlp and broadcasts too Ethereum chain

func (*Client) GetAccount

func (c *Client) GetAccount(pkey common.PubKey) (common.Account, error)

GetAccount gets account by address in eth client

func (*Client) GetAccountByAddress

func (c *Client) GetAccountByAddress(address string) (common.Account, error)

func (*Client) GetAddress

func (c *Client) GetAddress(poolPubKey common.PubKey) string

GetAddress return current signer address, it will be bech32 encoded address

func (*Client) GetChain

func (c *Client) GetChain() common.Chain

func (*Client) GetConfig

func (c *Client) GetConfig() config.ChainConfiguration

func (*Client) GetGasFee

func (c *Client) GetGasFee(count uint64) common.Gas

func (*Client) GetGasPrice

func (c *Client) GetGasPrice() (*big.Int, error)

func (*Client) GetHeight

func (c *Client) GetHeight() (int64, error)

func (*Client) GetNonce

func (c *Client) GetNonce(addr string) (uint64, error)

func (*Client) InitChainID

func (c *Client) InitChainID()

IsTestNet determinate whether we are running on test net by checking the status

func (*Client) SignTx

func (c *Client) SignTx(tx stypes.TxOutItem, height int64) ([]byte, error)

SignTx sign the the given TxArrayItem

func (*Client) Start

func (c *Client) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock)

func (*Client) Stop

func (c *Client) Stop()

type KeySignWrapper

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

KeySignWrapper is a wrap of private key and also tss instance

func (*KeySignWrapper) GetPrivKey

func (w *KeySignWrapper) GetPrivKey() *ecdsa.PrivateKey

func (*KeySignWrapper) GetPubKey

func (w *KeySignWrapper) GetPubKey() common.PubKey

func (*KeySignWrapper) Sign

func (w *KeySignWrapper) Sign(tx *etypes.Transaction, poolPubKey common.PubKey, signerPubKeys common.PubKeys) ([]byte, error)

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) 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) 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) SaveBlockMeta

func (t *LevelDBBlockMetaAccessor) SaveBlockMeta(height int64, blockMeta *types.BlockMeta) error

SaveBlockMeta persistent the given BlockMeta into storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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