spv

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//Unprocessed refill transaction index prefix
	UnTransaction string = "UnT-"

	//Cross-chain recharge unprocessed transaction index
	UnTransactionIndex = "UnTI"

	//Cross-chain recharge unprocessed transaction seek
	UnTransactionSeek = "UnTS"
)
View Source
const (
	DefaultConfigFilename = "./config.json"
)
View Source
const LogPath = "./logs-spv/"

Variables

View Source
var (
	Parameters configParams
	Version    string
)
View Source
var (
	SpvService *Service

	MinedBlockSub *event.TypeMuxSubscription
	Signers       map[ethCommon.Address]struct{} // Set of authorized signers at this moment
)

Functions

func AddrIsArbiter

func AddrIsArbiter(address ethCommon.Address) int8

Determine whether an address is an arbiter

func AddrIsArbiterWithElaHeight

func AddrIsArbiterWithElaHeight(address ethCommon.Address, elaHeight uint32) int8

Determine whether an address is an arbiter

func FindOutputFeeAndaddressByTxHash

func FindOutputFeeAndaddressByTxHash(transactionHash string) (*big.Int, ethCommon.Address, *big.Int)

FindOutputFeeAndaddressByTxHash Finds the eth recharge address, recharge amount, and transaction fee based on the main chain hash.

func GetCurrentElaHeight

func GetCurrentElaHeight() uint32

func GetCurrentProducers

func GetCurrentProducers() [][]byte

func GetElaChainHeight

func GetElaChainHeight() uint32

Get Ela Chain Height

func GetProducersByHeight

func GetProducersByHeight(height uint32) [][]byte

func GetUnTransactionNum

func GetUnTransactionNum(db DatabaseReader, Prefix string) uint64

func IteratorUnTransaction

func IteratorUnTransaction(from ethCommon.Address)

IteratorUnTransaction iterates before mining and processes existing spv refill transactions

func SendTransaction

func SendTransaction(from ethCommon.Address, elaTx string, fee *big.Int)

SendTransaction sends a reload transaction to txpool

func SpvDbInit

func SpvDbInit(spvdataDir string)

Spv database initialization

func UntilGetElaChainHeight

func UntilGetElaChainHeight() uint32

Until Get Ela Chain Height

func UpTransactionIndex

func UpTransactionIndex(elaTx string)

UpTransactionIndex records spv-aware refill transaction index

Types

type ChainParams

type ChainParams struct {
	Name               string
	PowLimit           *big.Int
	PowLimitBits       uint32
	TargetTimespan     time.Duration
	TargetTimePerBlock time.Duration
	AdjustmentFactor   int64
	MaxOrphanBlocks    int
	MinMemoryNodes     uint32
	SpendCoinbaseSpan  uint32
}

type Config

type Config struct {
	// DataDir is the data path to store db files peer addresses etc.
	DataDir string

	// ActiveNet indicates the ELA network to connect with.
	ActiveNet string

	// GenesisAddress is the address generated by the side chain genesis block.
	GenesisAddress string
}

type ConfigFile

type ConfigFile struct {
	ConfigFile Configuration `json:"Configuration"`
}

type Configuration

type Configuration struct {
	Magic                      uint32           `json:"Magic"`
	SpvMagic                   uint32           `json:"SpvMagic"`
	Version                    int              `json:"Version"`
	SeedList                   []string         `json:"SeedList"`
	SpvSeedList                []string         `json:"SpvSeedList"`
	SpvMinOutbound             int              `json:"SpvMinOutbound"`
	SpvMaxConnections          int              `json:"SpvMaxConnections"`
	SpvPrintLevel              int              `json:"SpvPrintLevel"`
	ExchangeRate               float64          `json:"ExchangeRate"`
	MinCrossChainTxFee         int              `json:"MinCrossChainTxFee"`
	HttpRestPort               int              `json:"HttpRestPort"`
	RestCertPath               string           `json:"RestCertPath"`
	RestKeyPath                string           `json:"RestKeyPath"`
	HttpInfoPort               uint16           `json:"HttpInfoPort"`
	HttpInfoStart              bool             `json:"HttpInfoStart"`
	OpenService                bool             `json:"OpenService"`
	HttpWsPort                 int              `json:"HttpWsPort"`
	WsHeartbeatInterval        time.Duration    `json:"WsHeartbeatInterval"`
	HttpJsonPort               int              `json:"HttpJsonPort"`
	OauthServerUrl             string           `json:"OauthServerUrl"`
	NoticeServerUrl            string           `json:"NoticeServerUrl"`
	NodePort                   uint16           `json:"NodePort"`
	WebSocketPort              int              `json:"WebSocketPort"`
	PrintLevel                 int              `json:"PrintLevel"`
	IsTLS                      bool             `json:"IsTLS"`
	CertPath                   string           `json:"CertPath"`
	KeyPath                    string           `json:"KeyPath"`
	CAPath                     string           `json:"CAPath"`
	MultiCoreNum               uint             `json:"MultiCoreNum"`
	MaxLogsSize                int64            `json:"MaxLogsSize"`
	MaxPerLogSize              int64            `json:"MaxPerLogSize"`
	MaxTxInBlock               int              `json:"MaxTransactionInBlock"`
	MaxBlockSize               int              `json:"MaxBlockSize"`
	PowConfiguration           PowConfiguration `json:"PowConfiguration"`
	FoundationAddress          string           `json:"FoundationAddress"`
	MainChainFoundationAddress string           `json:"MainChainFoundationAddress"`
}

type DatabaseReader

type DatabaseReader interface {
	Get(key []byte) (value []byte, err error)
}

DatabaseReader wraps the Get method of a backing data store.

type PowConfiguration

type PowConfiguration struct {
	PayToAddr        string `json:"PayToAddr"`
	MiningServerIP   string `josn:"MiningServerIP"`
	MiningServerPort int    `josn:"MiningServerPort"`
	MiningSelfPort   int    `josn:"MiningSelfPort"`
	TestNet          bool   `json:"testnet"`
	AutoMining       bool   `json:"AutoMining"`
	MinerInfo        string `json:"MinerInfo"`
	MinTxFee         int    `json:"MinTxFee"`
	ActiveNet        string `json:"ActiveNet"`
}

type Service

type Service struct {
	spv.DPOSSPVService
}

func NewService

func NewService(cfg *Config, s *node.Node) (*Service, error)

Spv service initialization

func (*Service) GetDatabase

func (s *Service) GetDatabase() *ethdb.LDBDatabase

func (*Service) VerifyElaHeader

func (s *Service) VerifyElaHeader(hash *common.Uint256) error

func (*Service) VerifyTransaction

func (s *Service) VerifyTransaction(tx *types.Transaction) error

Jump to

Keyboard shortcuts

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