sidechain

package
v0.0.0-...-d7dfbf7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockSaveOptionTemplate                    = 1 << 0
	BlockSaveOptionDeterministicPrivateKeySeed = 1 << 1
	BlockSaveOptionDeterministicBlobs          = 1 << 2
	BlockSaveOptionUncles                      = 1 << 3

	BlockSaveFieldSizeInBits = 8

	BlockSaveOffsetAddress    = BlockSaveFieldSizeInBits
	BlockSaveOffsetMainFields = BlockSaveFieldSizeInBits * 2
)
View Source
const (
	SideCoinbasePublicKey = transaction.TxExtraTagPubKey
	SideExtraNonce        = transaction.TxExtraTagNonce
	SideTemplateId        = transaction.TxExtraTagMergeMining
)
View Source
const BlockSaveEpochSize = 32

BlockSaveEpochSize could be up to 256?

View Source
const LargestMinimumDifficulty = 1000000000
View Source
const PoolBlockMaxTemplateSize = 128*1024 - (1 + 4)

PoolBlockMaxTemplateSize Max P2P message size (128 KB) minus BLOCK_RESPONSE header (5 bytes)

View Source
const SideExtraNonceMaxSize = SideExtraNonceSize + 10
View Source
const SideExtraNonceSize = 4
View Source
const SmallestMinimumDifficulty = 100000
View Source
const (
	UncleBlockDepth = 3
)

Variables

View Source
var ConsensusDefault = &Consensus{NetworkType: NetworkMainnet, PoolName: "mainnet test 2", TargetBlockTime: 10, MinimumDifficulty: 100000, ChainWindowSize: 2160, UnclePenalty: 20, HardForks: p2poolMainNetHardForks, Id: types.Hash{34, 175, 126, 231, 181, 11, 104, 146, 227, 153, 218, 107, 44, 108, 68, 39, 178, 81, 4, 212, 169, 4, 142, 0, 177, 110, 157, 240, 68, 7, 249, 24}}
View Source
var ConsensusMini = &Consensus{NetworkType: NetworkMainnet, PoolName: "mini", TargetBlockTime: 10, MinimumDifficulty: 100000, ChainWindowSize: 2160, UnclePenalty: 20, HardForks: p2poolMainNetHardForks, Id: types.Hash{57, 130, 201, 26, 149, 174, 199, 250, 66, 80, 189, 18, 108, 216, 194, 220, 136, 23, 63, 24, 64, 113, 221, 44, 219, 86, 39, 163, 53, 24, 126, 196}}

Functions

func BlocksInPPLNSWindow

func BlocksInPPLNSWindow(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, addWeightFunc PoolBlockWindowAddWeightFunc) (bottomHeight uint64, err error)

func CalculateOutputs

func CalculateOutputs(block *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, derivationCache DerivationCacheInterface, preAllocatedShares Shares, preAllocatedRewards []uint64) (outputs transaction.Outputs, bottomHeight uint64)

func GetDifficultyForNextBlock

func GetDifficultyForNextBlock(tip *PoolBlock, consensus *Consensus, getByTemplateId GetByTemplateIdFunc, preAllocatedDifficultyData []DifficultyData, preAllocatedTimestampData []uint64) (difficulty types.Difficulty, verifyError, invalidError error)

GetDifficultyForNextBlock Gets the difficulty at tip (the next block will require this difficulty) preAllocatedDifficultyData should contain enough capacity to fit all entries to iterate through. preAllocatedTimestampDifferences should contain enough capacity to fit all differences.

Ported from SideChain::get_difficulty() from C p2pool, somewhat based on Blockchain::get_difficulty_for_next_block() from Monero with the addition of uncles

func IsLongerChain

func IsLongerChain(block, candidate *PoolBlock, consensus *Consensus, getByTemplateId GetByTemplateIdFunc, getChainMainByHash GetChainMainByHashFunc) (isLonger, isAlternative bool)

func IterateBlocksInPPLNSWindow

func IterateBlocksInPPLNSWindow(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, addWeightFunc PoolBlockWindowAddWeightFunc, slotFunc func(slot PoolBlockWindowSlot)) error

func NetworkMajorVersion

func NetworkMajorVersion(consensus *Consensus, height uint64) uint8

func NextDifficulty

func NextDifficulty(consensus *Consensus, timestamps []uint64, difficultyData []DifficultyData) (nextDifficulty types.Difficulty, err error)

NextDifficulty returns the next block difficulty based on gathered timestamp/difficulty data Returns error on wrap/overflow/underflow on uint128 operations

func ShuffleSequence

func ShuffleSequence(shareVersion ShareVersion, privateKeySeed types.Hash, items int, swap func(i, j int))

ShuffleSequence Iterates through a swap sequence according to consensus parameters.

func ShuffleShares

func ShuffleShares[T any](shares []T, shareVersion ShareVersion, privateKeySeed types.Hash)

ShuffleShares Shuffles shares according to consensus parameters via ShuffleSequence. Requires pre-sorted shares based on address

func SplitReward

func SplitReward(preAllocatedRewards []uint64, reward uint64, shares Shares) (rewards []uint64)

func SplitRewardAllocate

func SplitRewardAllocate(reward uint64, shares Shares) (rewards []uint64)

Types

type Cache

type Cache interface {
	GetBlob(key []byte) (blob []byte, err error)
	SetBlob(key, blob []byte) (err error)
	RemoveBlob(key []byte) (err error)
}

type ChainMain

type ChainMain struct {
	Difficulty types.Difficulty
	Height     uint64
	Timestamp  uint64
	Reward     uint64
	Id         types.Hash
}

type CoinbaseExtraTag

type CoinbaseExtraTag int

type Consensus

type Consensus struct {
	NetworkType       NetworkType `json:"network_type"`
	PoolName          string      `json:"name"`
	PoolPassword      string      `json:"password"`
	TargetBlockTime   uint64      `json:"block_time"`
	MinimumDifficulty uint64      `json:"min_diff"`
	ChainWindowSize   uint64      `json:"pplns_window"`
	UnclePenalty      uint64      `json:"uncle_penalty"`

	// HardFork optional hardfork information for p2pool
	// If empty it will be filled with the default hardfork list to the corresponding NetworkType
	HardForks []HardFork `json:"hard_forks,omitempty"`

	Id types.Hash `json:"id"`
	// contains filtered or unexported fields
}

func NewConsensus

func NewConsensus(networkType NetworkType, poolName, poolPassword string, targetBlockTime, minimumDifficulty, chainWindowSize, unclePenalty uint64) *Consensus

func NewConsensusFromJSON

func NewConsensusFromJSON(data []byte) (*Consensus, error)

func (*Consensus) ApplyUnclePenalty

func (c *Consensus) ApplyUnclePenalty(weight types.Difficulty) (uncleWeight, unclePenalty types.Difficulty)

ApplyUnclePenalty Applies UnclePenalty efficiently

func (*Consensus) CalculateId

func (c *Consensus) CalculateId() types.Hash

func (*Consensus) CalculateSideChainIdFromBlobs

func (c *Consensus) CalculateSideChainIdFromBlobs(mainBlob, sideBlob []byte) (result types.Hash)

func (*Consensus) CalculateSideTemplateId

func (c *Consensus) CalculateSideTemplateId(share *PoolBlock) (result types.Hash)

func (*Consensus) CalculateSideTemplateIdPreAllocated

func (c *Consensus) CalculateSideTemplateIdPreAllocated(share *PoolBlock, buf []byte) (result types.Hash)

func (*Consensus) DefaultPort

func (c *Consensus) DefaultPort() uint16

func (*Consensus) GetHasher

func (c *Consensus) GetHasher() randomx.Hasher

func (*Consensus) InitHasher

func (c *Consensus) InitHasher(n int, flags ...randomx.Flag) error

func (*Consensus) IsDefault

func (c *Consensus) IsDefault() bool

func (*Consensus) IsMini

func (c *Consensus) IsMini() bool

func (*Consensus) SeedNode

func (c *Consensus) SeedNode() string

type ConsensusProvider

type ConsensusProvider interface {
	Consensus() *Consensus
}

type DerivationCache

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

func NewDerivationLRUCache

func NewDerivationLRUCache() *DerivationCache

func NewDerivationMapCache

func NewDerivationMapCache() *DerivationCache

func (*DerivationCache) Clear

func (d *DerivationCache) Clear()

func (*DerivationCache) GetDeterministicTransactionKey

func (d *DerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair

func (*DerivationCache) GetEphemeralPublicKey

func (d *DerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, txKeySlice crypto.PrivateKeySlice, txKeyScalar *crypto.PrivateKeyScalar, outputIndex uint64, hasher *sha3.HasherState) (crypto.PublicKeyBytes, uint8)

type DerivationCacheInterface

type DerivationCacheInterface interface {
	GetEphemeralPublicKey(a *address.PackedAddress, txKeySlice crypto.PrivateKeySlice, txKeyScalar *crypto.PrivateKeyScalar, outputIndex uint64, hasher *sha3.HasherState) (crypto.PublicKeyBytes, uint8)
	GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair
}

type DifficultyData

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

type FakeServer

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

func GetFakeTestServer

func GetFakeTestServer(consensus *Consensus) *FakeServer

func (*FakeServer) Broadcast

func (s *FakeServer) Broadcast(block *PoolBlock)

func (*FakeServer) ClearCachedBlocks

func (s *FakeServer) ClearCachedBlocks()

func (*FakeServer) ClientRPC

func (s *FakeServer) ClientRPC() *client.Client

func (*FakeServer) Consensus

func (s *FakeServer) Consensus() *Consensus

func (*FakeServer) Context

func (s *FakeServer) Context() context.Context

func (*FakeServer) GetBlob

func (s *FakeServer) GetBlob(key []byte) (blob []byte, err error)

func (*FakeServer) GetChainMainByHash

func (s *FakeServer) GetChainMainByHash(hash types.Hash) *ChainMain

func (*FakeServer) GetChainMainByHeight

func (s *FakeServer) GetChainMainByHeight(height uint64) *ChainMain

func (*FakeServer) GetChainMainTip

func (s *FakeServer) GetChainMainTip() *ChainMain

func (*FakeServer) GetDifficultyByHeight

func (s *FakeServer) GetDifficultyByHeight(height uint64) types.Difficulty

func (*FakeServer) GetMinerDataTip

func (s *FakeServer) GetMinerDataTip() *p2pooltypes.MinerData

func (*FakeServer) GetMinimalBlockHeaderByHash

func (s *FakeServer) GetMinimalBlockHeaderByHash(hash types.Hash) *mainblock.Header

func (*FakeServer) GetMinimalBlockHeaderByHeight

func (s *FakeServer) GetMinimalBlockHeaderByHeight(height uint64) *mainblock.Header

func (*FakeServer) RemoveBlob

func (s *FakeServer) RemoveBlob(key []byte) (err error)

func (*FakeServer) SetBlob

func (s *FakeServer) SetBlob(key, blob []byte) (err error)

func (*FakeServer) Store

func (s *FakeServer) Store(block *PoolBlock)

func (*FakeServer) SubmitBlock

func (s *FakeServer) SubmitBlock(block *mainblock.Block)

func (*FakeServer) UpdateBlockFound

func (s *FakeServer) UpdateBlockFound(data *ChainMain, block *PoolBlock)

func (*FakeServer) UpdateTip

func (s *FakeServer) UpdateTip(tip *PoolBlock)

type FullId

type FullId [FullIdSize]byte

func FullIdFromString

func FullIdFromString(s string) (FullId, error)

func (FullId) ExtraNonce

func (id FullId) ExtraNonce() uint32

func (FullId) Nonce

func (id FullId) Nonce() uint32

func (FullId) String

func (id FullId) String() string

func (FullId) TemplateId

func (id FullId) TemplateId() (h types.Hash)

type GetByMainHeightFunc

type GetByMainHeightFunc func(height uint64) UniquePoolBlockSlice

type GetByMainIdFunc

type GetByMainIdFunc func(h types.Hash) *PoolBlock

type GetBySideHeightFunc

type GetBySideHeightFunc func(height uint64) UniquePoolBlockSlice

type GetByTemplateIdFunc

type GetByTemplateIdFunc func(h types.Hash) *PoolBlock

type GetChainMainByHashFunc

type GetChainMainByHashFunc func(h types.Hash) *ChainMain

GetChainMainByHashFunc if h = types.ZeroHash, return tip

type HardFork

type HardFork struct {
	Version   uint8  `json:"version"`
	Height    uint64 `json:"height"`
	Threshold uint8  `json:"threshold"`
	Time      uint64 `json:"time"`
}

func NetworkHardFork

func NetworkHardFork(consensus *Consensus) []HardFork

type IterationCache

type IterationCache struct {
	Parent *PoolBlock
	Uncles []*PoolBlock
}

IterationCache Used for fast scan backwards, and of uncles Only maybe available in verified blocks

type NetworkType

type NetworkType int
const (
	NetworkInvalid NetworkType = iota
	NetworkMainnet
	NetworkTestnet
	NetworkStagenet
)

func (NetworkType) AddressNetwork

func (n NetworkType) AddressNetwork() (uint8, error)

func (NetworkType) MarshalJSON

func (n NetworkType) MarshalJSON() ([]byte, error)

func (NetworkType) String

func (n NetworkType) String() string

func (*NetworkType) UnmarshalJSON

func (n *NetworkType) UnmarshalJSON(b []byte) error

type NilDerivationCache

type NilDerivationCache struct {
}

func (*NilDerivationCache) Clear

func (d *NilDerivationCache) Clear()

func (*NilDerivationCache) GetDeterministicTransactionKey

func (d *NilDerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair

func (*NilDerivationCache) GetEphemeralPublicKey

func (d *NilDerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, _ crypto.PrivateKeySlice, txKeyScalar *crypto.PrivateKeyScalar, outputIndex uint64, hasher *sha3.HasherState) (crypto.PublicKeyBytes, uint8)

type P2PoolInterface

type P2PoolInterface interface {
	ConsensusProvider
	Cache
	Context() context.Context
	UpdateTip(tip *PoolBlock)
	Broadcast(block *PoolBlock)
	ClientRPC() *client.Client
	GetChainMainByHeight(height uint64) *ChainMain
	GetChainMainByHash(hash types.Hash) *ChainMain
	GetMinimalBlockHeaderByHeight(height uint64) *mainblock.Header
	GetMinimalBlockHeaderByHash(hash types.Hash) *mainblock.Header
	GetDifficultyByHeight(height uint64) types.Difficulty
	UpdateBlockFound(data *ChainMain, block *PoolBlock)
	SubmitBlock(block *mainblock.Block)
	GetChainMainTip() *ChainMain
	GetMinerDataTip() *p2pooltypes.MinerData
	Store(block *PoolBlock)
	ClearCachedBlocks()
}

type PoolBlock

type PoolBlock struct {
	Main mainblock.Block `json:"main"`

	Side SideData `json:"side"`

	Depth    atomic.Uint64 `json:"-"`
	Verified atomic.Bool   `json:"-"`
	Invalid  atomic.Bool   `json:"-"`

	WantBroadcast atomic.Bool `json:"-"`
	Broadcasted   atomic.Bool `json:"-"`

	LocalTimestamp     uint64       `json:"-"`
	CachedShareVersion ShareVersion `json:"share_version"`
	// contains filtered or unexported fields
}

func NewShareFromExportedBytes

func NewShareFromExportedBytes(buf []byte, consensus *Consensus, cacheInterface DerivationCacheInterface) (*PoolBlock, error)

NewShareFromExportedBytes Deprecated

func (*PoolBlock) AppendBinaryFlags

func (b *PoolBlock) AppendBinaryFlags(preAllocatedBuf []byte, pruned, compact bool) (buf []byte, err error)

func (*PoolBlock) BufferLength

func (b *PoolBlock) BufferLength() int

func (*PoolBlock) CalculateFullId

func (b *PoolBlock) CalculateFullId(consensus *Consensus) FullId

func (*PoolBlock) CalculateShareVersion

func (b *PoolBlock) CalculateShareVersion(consensus *Consensus) ShareVersion

func (*PoolBlock) CalculateTransactionPrivateKeySeed

func (b *PoolBlock) CalculateTransactionPrivateKeySeed() types.Hash

func (*PoolBlock) CoinbaseExtra

func (b *PoolBlock) CoinbaseExtra(tag CoinbaseExtraTag) []byte

func (*PoolBlock) CoinbaseId

func (b *PoolBlock) CoinbaseId() types.Hash

func (*PoolBlock) ExtraNonce

func (b *PoolBlock) ExtraNonce() uint32

func (*PoolBlock) FillPrivateKeys

func (b *PoolBlock) FillPrivateKeys(derivationCache DerivationCacheInterface)

func (*PoolBlock) FillTransactionParentIndices

func (b *PoolBlock) FillTransactionParentIndices(parent *PoolBlock) bool

func (*PoolBlock) FillTransactionsFromTransactionParentIndices

func (b *PoolBlock) FillTransactionsFromTransactionParentIndices(parent *PoolBlock) error

func (*PoolBlock) FromCompactReader

func (b *PoolBlock) FromCompactReader(consensus *Consensus, derivationCache DerivationCacheInterface, reader utils.ReaderAndByteReader) (err error)

FromCompactReader used in Protocol 1.1 and above

func (*PoolBlock) FromReader

func (b *PoolBlock) FromReader(consensus *Consensus, derivationCache DerivationCacheInterface, reader utils.ReaderAndByteReader) (err error)

func (*PoolBlock) FullId

func (b *PoolBlock) FullId() FullId

func (*PoolBlock) GetAddress

func (b *PoolBlock) GetAddress() address.PackedAddress

func (*PoolBlock) GetPrivateKeySeed

func (b *PoolBlock) GetPrivateKeySeed() types.Hash

func (*PoolBlock) GetTransactionOutputType

func (b *PoolBlock) GetTransactionOutputType() uint8

func (*PoolBlock) IsProofHigherThanDifficulty

func (b *PoolBlock) IsProofHigherThanDifficulty(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) bool

func (*PoolBlock) IsProofHigherThanDifficultyWithError

func (b *PoolBlock) IsProofHigherThanDifficultyWithError(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) (bool, error)

func (*PoolBlock) IsProofHigherThanMainDifficulty

func (b *PoolBlock) IsProofHigherThanMainDifficulty(hasher randomx.Hasher, difficultyFunc mainblock.GetDifficultyByHeightFunc, seedFunc mainblock.GetSeedByHeightFunc) bool

func (*PoolBlock) IsProofHigherThanMainDifficultyWithError

func (b *PoolBlock) IsProofHigherThanMainDifficultyWithError(hasher randomx.Hasher, difficultyFunc mainblock.GetDifficultyByHeightFunc, seedFunc mainblock.GetSeedByHeightFunc) (bool, error)

func (*PoolBlock) MainDifficulty

func (*PoolBlock) MainId

func (b *PoolBlock) MainId() types.Hash

func (*PoolBlock) MarshalBinary

func (b *PoolBlock) MarshalBinary() ([]byte, error)

func (*PoolBlock) MarshalBinaryFlags

func (b *PoolBlock) MarshalBinaryFlags(pruned, compact bool) ([]byte, error)

func (*PoolBlock) NeedsCompactTransactionFilling

func (b *PoolBlock) NeedsCompactTransactionFilling() bool

func (*PoolBlock) NeedsPreProcess

func (b *PoolBlock) NeedsPreProcess() bool

func (*PoolBlock) PowHash

func (*PoolBlock) PowHashWithError

func (b *PoolBlock) PowHashWithError(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) (powHash types.Hash, err error)

func (*PoolBlock) PreProcessBlock

func (b *PoolBlock) PreProcessBlock(consensus *Consensus, derivationCache DerivationCacheInterface, preAllocatedShares Shares, difficultyByHeight mainblock.GetDifficultyByHeightFunc, getTemplateById GetByTemplateIdFunc) (missingBlocks []types.Hash, err error)

PreProcessBlock processes and fills the block data from either pruned or compact modes

func (*PoolBlock) PreProcessBlockWithOutputs

func (b *PoolBlock) PreProcessBlockWithOutputs(getTemplateById GetByTemplateIdFunc, calculateOutputs func() (outputs transaction.Outputs, bottomHeight uint64)) (missingBlocks []types.Hash, err error)

PreProcessBlockWithOutputs processes and fills the block data from either pruned or compact modes

func (*PoolBlock) ShareVersion

func (b *PoolBlock) ShareVersion() ShareVersion

func (*PoolBlock) ShareVersionSignaling

func (b *PoolBlock) ShareVersionSignaling() ShareVersion

func (*PoolBlock) SideTemplateId

func (b *PoolBlock) SideTemplateId(consensus *Consensus) types.Hash

func (*PoolBlock) UnmarshalBinary

func (b *PoolBlock) UnmarshalBinary(consensus *Consensus, derivationCache DerivationCacheInterface, data []byte) error

type PoolBlockWindowAddWeightFunc

type PoolBlockWindowAddWeightFunc func(b *PoolBlock, weight types.Difficulty)

type PoolBlockWindowSlot

type PoolBlockWindowSlot struct {
	Block *PoolBlock
	// Uncles that count for the window weight
	Uncles UniquePoolBlockSlice
}

type PreAllocatedSharesPool

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

func NewPreAllocatedSharesPool

func NewPreAllocatedSharesPool[T uint64 | int](n T) *PreAllocatedSharesPool

func (*PreAllocatedSharesPool) Get

func (p *PreAllocatedSharesPool) Get() Shares

func (*PreAllocatedSharesPool) Put

func (p *PreAllocatedSharesPool) Put(s Shares)

type Share

type Share struct {
	Address address.PackedAddress
	Weight  types.Difficulty
}

type ShareVersion

type ShareVersion uint8
const (
	ShareVersion_None ShareVersion = 0
	ShareVersion_V1   ShareVersion = 1
	ShareVersion_V2   ShareVersion = 2
)

func P2PoolShareVersion

func P2PoolShareVersion(consensus *Consensus, timestamp uint64) ShareVersion

func (ShareVersion) String

func (v ShareVersion) String() string

type Shares

type Shares []*Share

func GetShares

func GetShares(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, preAllocatedShares Shares) (shares Shares, bottomHeight uint64)

func GetSharesOrdered

func GetSharesOrdered(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, preAllocatedShares Shares) (shares Shares, bottomHeight uint64)

func PreAllocateShares

func PreAllocateShares[T uint64 | int](n T) Shares

func (Shares) Clone

func (s Shares) Clone() (o Shares)

func (Shares) Compact

func (s Shares) Compact() Shares

Compact Merges duplicate Share entries based on Address len(s) must be greater than 0

func (Shares) Index

func (s Shares) Index(addr address.PackedAddress) int

func (Shares) Sort

func (s Shares) Sort()

Sort Consensus way of sorting Shares

type SideChain

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

func NewSideChain

func NewSideChain(server P2PoolInterface) *SideChain

func (*SideChain) AddPoolBlock

func (c *SideChain) AddPoolBlock(block *PoolBlock) (err error)

func (*SideChain) AddPoolBlockExternal

func (c *SideChain) AddPoolBlockExternal(block *PoolBlock) (missingBlocks []types.Hash, err error, ban bool)

func (*SideChain) BlockSeen

func (c *SideChain) BlockSeen(block *PoolBlock) bool

func (*SideChain) BlockUnsee

func (c *SideChain) BlockUnsee(block *PoolBlock)

func (*SideChain) Consensus

func (c *SideChain) Consensus() *Consensus

func (*SideChain) DerivationCache

func (c *SideChain) DerivationCache() *DerivationCache

func (*SideChain) Difficulty

func (c *SideChain) Difficulty() types.Difficulty

func (*SideChain) GetChainTip

func (c *SideChain) GetChainTip() *PoolBlock

func (*SideChain) GetDifficulty

func (c *SideChain) GetDifficulty(tip *PoolBlock) (difficulty types.Difficulty, verifyError, invalidError error)

func (*SideChain) GetHighestKnownTip

func (c *SideChain) GetHighestKnownTip() *PoolBlock

func (*SideChain) GetMissingBlocks

func (c *SideChain) GetMissingBlocks() []types.Hash

func (*SideChain) GetParent

func (c *SideChain) GetParent(block *PoolBlock) *PoolBlock

func (*SideChain) GetPoolBlockByTemplateId

func (c *SideChain) GetPoolBlockByTemplateId(id types.Hash) *PoolBlock

func (*SideChain) GetPoolBlockCount

func (c *SideChain) GetPoolBlockCount() int

func (*SideChain) GetPoolBlocksByHeight

func (c *SideChain) GetPoolBlocksByHeight(height uint64) []*PoolBlock

func (*SideChain) GetPoolBlocksFromTip

func (c *SideChain) GetPoolBlocksFromTip(id types.Hash) (chain, uncles UniquePoolBlockSlice)

func (*SideChain) GetPoolBlocksFromTipWithDepth

func (c *SideChain) GetPoolBlocksFromTipWithDepth(id types.Hash, depth uint64) (chain, uncles UniquePoolBlockSlice)

func (*SideChain) GetPossibleUncles

func (c *SideChain) GetPossibleUncles(tip *PoolBlock, forHeight uint64) (uncles []types.Hash)

func (*SideChain) IsLongerChain

func (c *SideChain) IsLongerChain(block, candidate *PoolBlock) (isLonger, isAlternative bool)

func (*SideChain) LastUpdated

func (c *SideChain) LastUpdated() uint64

func (*SideChain) PreCalcFinished

func (c *SideChain) PreCalcFinished() bool

func (*SideChain) PreprocessBlock

func (c *SideChain) PreprocessBlock(block *PoolBlock) (missingBlocks []types.Hash, err error)

func (*SideChain) Server

func (c *SideChain) Server() P2PoolInterface

func (*SideChain) WatchMainChainBlock

func (c *SideChain) WatchMainChainBlock(mainData *ChainMain, possibleId types.Hash)

type SideData

type SideData struct {
	PublicKey              address.PackedAddress `json:"public_key"`
	CoinbasePrivateKeySeed types.Hash            `json:"coinbase_private_key_seed,omitempty"`
	// CoinbasePrivateKey filled or calculated on decoding
	CoinbasePrivateKey   crypto.PrivateKeyBytes `json:"coinbase_private_key"`
	Parent               types.Hash             `json:"parent"`
	Uncles               []types.Hash           `json:"uncles,omitempty"`
	Height               uint64                 `json:"height"`
	Difficulty           types.Difficulty       `json:"difficulty"`
	CumulativeDifficulty types.Difficulty       `json:"cumulative_difficulty"`

	// ExtraBuffer available in ShareVersion ShareVersion_V2 and above
	ExtraBuffer struct {
		SoftwareId          p2pooltypes.SoftwareId      `json:"software_id"`
		SoftwareVersion     p2pooltypes.SoftwareVersion `json:"software_version"`
		RandomNumber        uint32                      `json:"random_number"`
		SideChainExtraNonce uint32                      `json:"side_chain_extra_nonce"`
	} `json:"extra_buffer,omitempty"`
}

func (*SideData) AppendBinary

func (b *SideData) AppendBinary(preAllocatedBuf []byte, version ShareVersion) (buf []byte, err error)

func (*SideData) BufferLength

func (b *SideData) BufferLength() int

func (*SideData) FromReader

func (b *SideData) FromReader(reader utils.ReaderAndByteReader, version ShareVersion) (err error)

func (*SideData) MarshalBinary

func (b *SideData) MarshalBinary(version ShareVersion) (buf []byte, err error)

func (*SideData) UnmarshalBinary

func (b *SideData) UnmarshalBinary(data []byte, version ShareVersion) error

type UniquePoolBlockSlice

type UniquePoolBlockSlice []*PoolBlock

func (UniquePoolBlockSlice) Get

func (UniquePoolBlockSlice) GetHeight

func (s UniquePoolBlockSlice) GetHeight(height uint64) (result UniquePoolBlockSlice)

Jump to

Keyboard shortcuts

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