spv

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: GPL-3.0 Imports: 51 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DefaultConfigFilename = "./spvconfig.json"
	Foundation            = "Foundation"
	CRCAddress            = "CRCAddress"
	GenesisBlock          = "GenesisBlock"
	PowLimit              = "PowLimit"
)
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"

	// Fixed number of extra-data prefix bytes reserved for signer vanity
	ExtraVanity = 32

	// Fixed number of extra-data suffix bytes reserved for signer seal
	ExtraSeal = 65

	// Fixed height of ela chain height with LitterEnd encode
	ExtraElaHeight = 8

	IsOnlyCRConsensus = true
)
View Source
const LogPath = "./logs-spv/"

Variables

View Source
var (
	SpvService *Service

	MinedBlockSub *event.TypeMuxSubscription

	GetDefaultSingerAddr func() ethCommon.Address

	PbftEngine consensus.IPbftEngine

	ErrMainTxHashPresence = errors.New("main txhash presence")
)

Functions

func Close added in v0.2.0

func Close()

func DumpNextDposInfo

func DumpNextDposInfo() []peer.PID

func FindOutRechargeInput

func FindOutRechargeInput(transactionHash string) []byte

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 GetArbiters

func GetArbiters() ([]string, int, error)

func GetClient added in v0.2.0

func GetClient() *ethclient.Client

func GetCurrentConsensusMode added in v0.2.0

func GetCurrentConsensusMode() spv.ConsensusAlgorithm

func GetFailedRechargeTxByHash added in v0.2.0

func GetFailedRechargeTxByHash(hash string) string

func GetFailedRechargeTxs added in v0.2.0

func GetFailedRechargeTxs(height uint64) []string

func GetProducers

func GetProducers(elaHeight uint64) ([][]byte, int, error)

func GetSpvHeight

func GetSpvHeight() uint64

func GetTotalProducersCount

func GetTotalProducersCount() int

func GetUnTransactionNum

func GetUnTransactionNum(db DatabaseReader, Prefix string) uint64

func GetWorkingHeight

func GetWorkingHeight() uint32

func InitNextTurnDposInfo

func InitNextTurnDposInfo()

func IsFailedElaTx added in v0.2.0

func IsFailedElaTx(elaTx string) (bool, error)

func IsNexturnBlock

func IsNexturnBlock(block interface{}) bool

func IsPackagedElaTx added in v0.2.0

func IsPackagedElaTx(elaTx string) (bool, error)

func IsSmallCrossTxByData added in v0.2.0

func IsSmallCrossTxByData(data []byte) (string, string, []string, uint64)

func IteratorUnTransaction

func IteratorUnTransaction(from ethCommon.Address)

IteratorUnTransaction iterates before mining and processes existing spv refill transactions

func MainChainIsPowMode

func MainChainIsPowMode() bool

func MinedBroadcastLoop

func MinedBroadcastLoop(minedBlockSub *event.TypeMuxSubscription,
	ondutySub *event.TypeMuxSubscription,
	smallCrossTxSub *event.TypeMuxSubscription)

minedBroadcastLoop Mining awareness, eth can initiate a recharge transaction after the block

func NotifySmallCrossTx added in v0.2.0

func NotifySmallCrossTx(tx core.Transaction)

func OnReceivedRechargeTx added in v0.2.0

func OnReceivedRechargeTx(tx core.Transaction) error

func OnTx2Failed added in v0.2.0

func OnTx2Failed(elaTx string)

func ResetConfigWithReflect

func ResetConfigWithReflect(params *config.Params, spvConfig *spv.Config)

func SafeAdd added in v0.2.0

func SafeAdd(a int, b int) (int, error)

func SafeFixed64Minus added in v0.2.0

func SafeFixed64Minus(a common.Fixed64, b common.Fixed64) (common.Fixed64, error)

func SafeMinus added in v0.2.0

func SafeMinus(a int, b int) (int, error)

func SafeUInt64Minus added in v0.2.0

func SafeUInt64Minus(a uint64, b uint64) (uint64, error)

func SendEvilProof

func SendEvilProof(addr ethCommon.Address, info interface{})

func SendTransaction

func SendTransaction(from ethCommon.Address, elaTx string, fee *big.Int) (err error, finished bool)

SendTransaction sends a reload transaction to txpool

func SpvDbInit

func SpvDbInit(spvdataDir string)

Spv database initialization

func SpvIsWorkingHeight

func SpvIsWorkingHeight() bool

func UpTransactionIndex

func UpTransactionIndex(elaTx string)

UpTransactionIndex records spv-aware refill transaction index

func VerifySmallCrossTx added in v0.2.0

func VerifySmallCrossTx(rawTxID, rawTx string, signatures []string,
	blockHeight uint64) (bool, error)

Types

type BlockListener

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

func (*BlockListener) BlockHeight

func (l *BlockListener) BlockHeight() uint32

func (*BlockListener) NotifyBlock

func (l *BlockListener) NotifyBlock(block *util.Block)

func (*BlockListener) RegisterFunc

func (l *BlockListener) RegisterFunc(handleFunc func(block interface{}) error)

func (*BlockListener) StoreAuxBlock

func (l *BlockListener) StoreAuxBlock(block interface{})

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 Configuration

type Configuration struct {
	// Exegesis in file Elastos.ELA/common/config/params.go
	Magic                    uint32         `json:"Magic"`
	DefaultPort              uint16         `json:"DefaultPort"`
	DNSSeeds                 []string       `json:"DNSSeeds"`
	ListenAddrs              []string       `json:"ListenAddrs"`
	Foundation               string         `json:"Foundation"`
	CRCAddress               string         `json:"CRCAddress"`
	PowLimit                 *big.Int       `json:"PowLimit"`
	PowLimitBits             uint32         `json:"PowLimitBits"`
	TargetTimespan           time.Duration  `json:"TargetTimespan"`
	TargetTimePerBlock       time.Duration  `json:"TargetTimePerBlock"`
	AdjustmentFactor         int64          `json:"AdjustmentFactor"`
	RewardPerBlock           common.Fixed64 `json:"RewardPerBlock"`
	CoinbaseMaturity         uint32         `json:"CoinbaseMaturity"`
	DisableTxFilters         bool           `json:"DisableTxFilters"`
	MinTransactionFee        common.Fixed64 `json:"MinTransactionFee"`
	MinCrossChainTxFee       common.Fixed64 `json:"MinCrossChainTxFee"`
	OriginArbiters           []string       `json:"OriginArbiters"`
	CheckAddressHeight       uint32         `json:"CheckAddressHeight"`
	VoteStartHeight          uint32         `json:"VoteStartHeight"`
	CRCOnlyDPOSHeight        uint32         `json:"CRCOnlyDPOSHeight"`
	PublicDPOSHeight         uint32         `json:"PublicDPOSHeight"`
	CRCArbiters              []string       `json:"CRCArbiters"`
	DPoSMagic                uint32         `json:"DPoSMagic"`
	DPoSDefaultPort          uint16         `json:"DPoSDefaultPort"`
	PreConnectOffset         uint32         `json:"PreConnectOffset"`
	GeneralArbiters          int            `json:"GeneralArbiters"`
	CandidateArbiters        int            `json:"CandidateArbiters"`
	ToleranceDuration        time.Duration  `json:"ToleranceDuration"`
	MaxInactiveRounds        uint32         `json:"MaxInactiveRounds"`
	InactivePenalty          common.Fixed64 `json:"InactivePenalty"`
	EmergencyInactivePenalty common.Fixed64 `json:"EmergencyInactivePenalty"`
	MaxLogsSize              int64          `json:"MaxLogsSize"`
	MaxPerLogSize            int64          `json:"MaxPerLogSize"`
	SpvPrintLevel            uint32         `json:"SpvPrintLevel"`
	PermanentPeers           []string       `json:"PermanentPeers"`
}

type DatabaseReader

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

DatabaseReader wraps the Get method of a backing data store.

type PreferParams

type PreferParams struct {
	Config Configuration `json:"Configuration"`
}
var PreferConfig PreferParams

type Service

type Service struct {
	spv.SPVService
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg *Config, client *rpc.Client, tmux *event.TypeMux, dynamicArbiterHeight uint64) (*Service, error)

Spv service initialization

func (*Service) GetDatabase

func (s *Service) GetDatabase() *leveldb.Database

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