chain

package
v0.0.0-...-9fdd194 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0, MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDelay          = 1 * time.Minute
	CancellationDepth = 6
)
View Source
const (
	ConstCodeInit    = 1
	ConstCodeSuccess = 2
	ConstCodeError   = 3
)

code

Variables

View Source
var (
	ChainObject  ChainInfo
	SettleObject SettleInfo

	StateStore storage.StateStorer
)
View Source
var (
	CodeBttc = ConstCodeInit
	ErrBttc  error

	CodeStatus = ConstCodeInit
	ErrStatus  error
)
View Source
var DefaultStoreChainId = int64(-1)

Functions

func BackUpStateStore

func BackUpStateStore(dataDir string, suffix string) error

func GetBttcByKey

func GetBttcByKey(privKey string) (defaultAddr string, _err error)

func GetBttcNonDaemon

func GetBttcNonDaemon(env cmds.Environment) (defaultAddr string, _err error)

after btfs init

func GetChainIdFromDisk

func GetChainIdFromDisk(stateStorer storage.StateStorer) (int64, error)

get chain id from leveldb

func GetOnlineServer

func GetOnlineServer(chainId int64) string

func GetStateStorePath

func GetStateStorePath(dataDir string) string

func GetTxHash

func GetTxHash(stateStore storage.StateStorer) ([]byte, error)

func GetTxNextBlock

func GetTxNextBlock(ctx context.Context, backend transaction.Backend, monitor transaction.Monitor, duration time.Duration, trx []byte, blockHash string) ([]byte, error)

func GetVaultNonDaemon

func GetVaultNonDaemon(env cmds.Environment) (defaultAddr string, err error)

after btfs init

func GetWalletImportPrvKey

func GetWalletImportPrvKey(env cmds.Environment) (string, error)

after btfs init

func InitStateStore

func InitStateStore(dataDir string) (ret storage.StateStorer, err error)

func StoreChainIdIfNotExists

func StoreChainIdIfNotExists(chainID int64, statestore storage.StateStorer) error

func StoreChainIdToDisk

func StoreChainIdToDisk(ChainId int64, stateStorer storage.StateStorer) error

add chain id into leveldb

func StoreOnline

func StoreOnline(lastOnlineInfo *LastOnlineInfo) error

Types

type ChainInfo

type ChainInfo struct {
	Chainconfig        config.ChainConfig
	Backend            transaction.Backend
	OverlayAddress     common.Address
	Signer             crypto.Signer
	ChainID            int64
	PeerID             string
	TransactionMonitor transaction.Monitor
	TransactionService transaction.Service
}

func InitChain

func InitChain(
	ctx context.Context,
	stateStore storage.StateStorer,
	signer crypto.Signer,
	pollingInterval time.Duration,
	chainID int64,
	peerid string,
	chainconfig *config.ChainConfig,
) (*ChainInfo, error)

InitChain will initialize the Ethereum backend at the given endpoint and set up the Transaction Service to interact with it using the provided signer.

type LastOnlineInfo

type LastOnlineInfo struct {
	LastSignedInfo onlinePb.SignedInfo
	LastSignature  string
	LastTime       time.Time
}

func GetLastOnline

func GetLastOnline() (*LastOnlineInfo, error)

func GetReportOnlineListDailyOK

func GetReportOnlineListDailyOK() ([]*LastOnlineInfo, error)

GetReportOnlineListDailyOK store tx list

func SetReportOnlineListDailyOK

func SetReportOnlineListDailyOK(r *LastOnlineInfo) ([]*LastOnlineInfo, error)

SetReportOnlineListDailyOK store online daily list

type LastOnlineInfoRet

type LastOnlineInfoRet struct {
	LastSignedInfo onlinePb.SignedInfo `json:"last_signed_info"`
	LastSignature  string              `json:"last_signature"`
	LastTime       time.Time           `json:"last_time""`
}

type LevelDbReportStatusInfo

type LevelDbReportStatusInfo struct {
	Peer           string    `json:"peer"`
	BttcAddress    string    `json:"bttc_addr"`
	StatusContract string    `json:"status_contract"`
	Nonce          uint32    `json:"nonce"`
	TxHash         string    `json:"tx_hash"`
	GasSpend       string    `json:"gas_spend"`
	ReportTime     time.Time `json:"report_time"`
	IncreaseNonce  uint32    `json:"increase_nonce"`
}

func GetReportStatusListOK

func GetReportStatusListOK() ([]*LevelDbReportStatusInfo, error)

GetReportStatusListOK store tx list

func SetReportStatusListOK

func SetReportStatusListOK(r *LevelDbReportStatusInfo) ([]*LevelDbReportStatusInfo, error)

SetReportStatusListOK store tx list

type ReportOnlineLastTimeDaily

type ReportOnlineLastTimeDaily struct {
	EveryDaySeconds int64
	LastReportTime  time.Time
}

func GetReportOnlineLastTimeDaily

func GetReportOnlineLastTimeDaily() (*ReportOnlineLastTimeDaily, error)

func SetReportOnlineLastTimeDailyOK

func SetReportOnlineLastTimeDailyOK() (*ReportOnlineLastTimeDaily, error)

type ReportStatusInfo

type ReportStatusInfo struct {
	ReportStatusSeconds int64
	LastReportTime      time.Time
}

func GetReportStatus

func GetReportStatus() (*ReportStatusInfo, error)

func SetReportStatusOK

func SetReportStatusOK() (*ReportStatusInfo, error)

type SettleInfo

type SettleInfo struct {
	Factory        vault.Factory
	VaultService   vault.Service
	ChequeStore    vault.ChequeStore
	CashoutService vault.CashoutService
	SwapService    *swap.Service
	OracleService  priceoracle.Service
	BttcService    bttc.Service
}

func InitSettlement

func InitSettlement(
	ctx context.Context,
	stateStore storage.StateStorer,
	chaininfo *ChainInfo,
	deployGasPrice string,
	chainID int64,
) (*SettleInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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