poc

package module
v0.0.0-...-2c47f55 Latest Latest
Warning

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

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

README

go-poc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateAvgBaseTarget

func CalculateAvgBaseTarget(chain consensus.ChainReader, from consensus.Header, offset uint32) (*big.Int, consensus.Header)

func CalculateBaseTarget

func CalculateBaseTarget(chain consensus.ChainReader, prev consensus.Header, poc *Poc) *big.Int

func CalculateDeadline

func CalculateDeadline(genSig types.Byte32, scoopData types.Byte64, lastBaseTarget uint64) *big.Int

baseTarget from prev header !!

func CalculateDeadlineByHit

func CalculateDeadlineByHit(hit *big.Int, lastBaseTarget uint64) *big.Int

func CalculateDifficulty

func CalculateDifficulty(baseTarget *big.Int) *big.Int

func CalculateGenerationSignature

func CalculateGenerationSignature(lastGenSig types.Byte32, lastGenId uint64) types.Byte32

func CalculateHit

func CalculateHit(genSig types.Byte32, scoopData types.Byte64) *big.Int

func CalculateScoop

func CalculateScoop(genSig types.Byte32, height uint64) int32

Types

type Config

type Config struct {
	AvgBaseTargetNum  uint32
	ConsensusInterval uint32
	MaxBaseTarget     uint64

	Gen Genenis
}

func (*Config) Default

func (self *Config) Default()

func (*Config) GetGenesisConsensusData

func (self *Config) GetGenesisConsensusData() ([]byte, error)

type ConsensusData

type ConsensusData struct {
	GenerationSignature types.Byte32  `json: "generationSignature"`
	Nonce               uint64        `json: "nonce"`
	GenId               uint64        `json: "genId"`
	BaseTarget          *types.BigInt `json: "baseTarget"`

	Deadline *types.BigInt `msg:"-" json: "deadline"`
}

func GetConsensusDataFromHeader

func GetConsensusDataFromHeader(header consensus.Header) (*ConsensusData, error)

func (*ConsensusData) DecodeMsg

func (z *ConsensusData) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*ConsensusData) EncodeMsg

func (z *ConsensusData) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*ConsensusData) MarshalMsg

func (z *ConsensusData) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*ConsensusData) Msgsize

func (z *ConsensusData) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (ConsensusData) String

func (self ConsensusData) String() string

func (*ConsensusData) UnWrap

func (self *ConsensusData) UnWrap(oriConsensusData []byte) error

func (*ConsensusData) UnmarshalMsg

func (z *ConsensusData) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

func (*ConsensusData) Wrap

func (self *ConsensusData) Wrap() ([]byte, error)

type Genenis

type Genenis struct {
	GenerationSignature types.Byte32
	Nonce               uint64
	GenId               uint64
}

type Poc

type Poc struct {
	Config
}

Currently only support poc2 !!!

func (Poc) Forge

func (self Poc) Forge(chain consensus.ChainReader, header consensus.Header) (consensus.Data, error)

func (Poc) VerifyForge

func (self Poc) VerifyForge(chain consensus.ChainReader, header consensus.Header) error

func (Poc) VerifyHeader

func (self Poc) VerifyHeader(chain consensus.ChainReader, header consensus.Header) error

func (Poc) VerifyHeaderWithoutForge

func (self Poc) VerifyHeaderWithoutForge(chain consensus.ChainReader, header consensus.Header) error

type SimplePlotter

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

func (SimplePlotter) GetScoop

func (self SimplePlotter) GetScoop(pos int32) types.Byte64

func (*SimplePlotter) PlotPoC1

func (self *SimplePlotter) PlotPoC1(addr uint64, nonce uint64)

func (*SimplePlotter) PlotPoC2

func (self *SimplePlotter) PlotPoC2(addr uint64, nonce uint64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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