powpool

package
v1.2.0-fork5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: LGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncompletePowBlocksInEpoch = errors.New("incomplete pow blocks in epoch")
)

Functions

func DecodeSignatureScript

func DecodeSignatureScript(bs []byte) (uint32, string)

scriptSig contains 4 segments: encoded Height (vaired length) + Seqence (4 bytes) + TimeStamp (8 bytes) + Beneficiary str(40 bytes) + Optional(pool tag) only returns height, beneficairy as items[0],[3]

func NewPowObject

func NewPowObject(powBlockInfo *PowBlockInfo) *powObject

func SetGlobPowPoolInst

func SetGlobPowPoolInst(pool *PowPool) bool

Types

type Options

type Options struct {
	Node            string
	Port            int
	User            string
	Pass            string
	Limit           int
	LimitPerAccount int
	MaxLifetime     time.Duration
}

Options options for tx pool.

type PowBlockEvent

type PowBlockEvent struct {
	BlockInfo *PowBlockInfo
}

PowBlockEvent will be posted when pow is added or status changed.

type PowBlockInfo

type PowBlockInfo struct {
	// Pow header part
	Version        uint32
	HashPrevBlock  meter.Bytes32
	HashMerkleRoot meter.Bytes32
	Timestamp      uint32
	NBits          uint32
	Nonce          uint32

	HeaderHash  meter.Bytes32
	Beneficiary meter.Address
	PowHeight   uint32

	// Raw block
	PosRaw []byte
	PowRaw []byte
}

func GetPowGenesisBlockInfo

func GetPowGenesisBlockInfo() *PowBlockInfo

func NewPowBlockInfo

func NewPowBlockInfo(raw []byte) *PowBlockInfo

func NewPowBlockInfoFromPosKBlock

func NewPowBlockInfoFromPosKBlock(posBlock *block.Block) *PowBlockInfo

func NewPowBlockInfoFromPowBlock

func NewPowBlockInfoFromPowBlock(powBlock *wire.MsgBlock) *PowBlockInfo

func (*PowBlockInfo) HashID

func (info *PowBlockInfo) HashID() meter.Bytes32

func (*PowBlockInfo) ToString

func (info *PowBlockInfo) ToString() string

type PowPool

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

PowPool maintains unprocessed transactions.

var (
	GlobPowPoolInst *PowPool
)

func GetGlobPowPoolInst

func GetGlobPowPoolInst() *PowPool

func New

func New(options Options, chain *chain.Chain, stateCreator *state.Creator) *PowPool

New create a new PowPool instance. Shutdown is required to be called at end.

func (*PowPool) Add

func (p *PowPool) Add(newPowBlockInfo *PowBlockInfo) error

Add add new pow block into pool. It's not assumed as an error if the pow to be added is already in the pool,

func (*PowPool) Close

func (p *PowPool) Close()

Close cleanup inner go routines.

func (*PowPool) GetCurCoef added in v1.2.0

func (pool *PowPool) GetCurCoef() (curCoef int64)

func (*PowPool) GetPowDecision

func (p *PowPool) GetPowDecision() (bool, *PowResult)

consensus APIs

func (*PowPool) GetStatus added in v1.2.0

func (p *PowPool) GetStatus() PowPoolStatus

func (*PowPool) InitialAddKframe

func (p *PowPool) InitialAddKframe(newPowBlockInfo *PowBlockInfo) error

func (*PowPool) Remove

func (p *PowPool) Remove(powID meter.Bytes32) bool

Remove removes powObj from pool by its ID.

func (*PowPool) ReplayFrom

func (p *PowPool) ReplayFrom(startHeight int32) error

func (*PowPool) SubscribePowBlockEvent

func (p *PowPool) SubscribePowBlockEvent(ch chan *PowBlockEvent) event.Subscription

SubscribePowBlockEvent receivers will receive a pow

func (*PowPool) VerifyNPowBlockPerEpoch added in v1.2.0

func (p *PowPool) VerifyNPowBlockPerEpoch() bool

func (*PowPool) Wash

func (p *PowPool) Wash() error

type PowPoolStatus added in v1.2.0

type PowPoolStatus struct {
	Status       string
	KFrameHeight uint32
	LatestHeight uint32
	PoolSize     int
}

type PowResult

type PowResult struct {
	Nonce         uint32
	Rewards       []PowReward
	Difficaulties *big.Int
	Raw           []block.PowRawBlock
}

pow decisions

func NewPowResult

func NewPowResult(nonce uint32) *PowResult

==============APIs for consensus ===================

type PowReward

type PowReward struct {
	Rewarder meter.Address
	Value    big.Int
}

type RPCData

type RPCData struct {
	Jsonrpc string   `json:"jsonrpc"`
	Id      string   `json:"id"`
	Method  string   `json:"method"`
	Params  []string `json:"params"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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