Documentation ¶
Index ¶
- Constants
- Variables
- func BlocksInPPLNSWindow(tip *PoolBlock, consensus *Consensus, ...) (bottomHeight uint64, err error)
- func CalculateOutputs(block *PoolBlock, consensus *Consensus, ...) (outputs transaction.Outputs, bottomHeight uint64)
- func GetDifficultyForNextBlock(tip *PoolBlock, consensus *Consensus, getByTemplateId GetByTemplateIdFunc, ...) (difficulty types.Difficulty, verifyError, invalidError error)
- func IsLongerChain(block, candidate *PoolBlock, consensus *Consensus, ...) (isLonger, isAlternative bool)
- func IterateBlocksInPPLNSWindow(tip *PoolBlock, consensus *Consensus, ...) error
- func NetworkMajorVersion(consensus *Consensus, height uint64) uint8
- func NextDifficulty(consensus *Consensus, timestamps []uint64, difficultyData []DifficultyData) (nextDifficulty types.Difficulty, err error)
- func ShuffleSequence(shareVersion ShareVersion, privateKeySeed types.Hash, items int, ...)
- func ShuffleShares[T any](shares []T, shareVersion ShareVersion, privateKeySeed types.Hash)
- func SplitReward(preAllocatedRewards []uint64, reward uint64, shares Shares) (rewards []uint64)
- func SplitRewardAllocate(reward uint64, shares Shares) (rewards []uint64)
- type Cache
- type ChainMain
- type CoinbaseExtraTag
- type Consensus
- func (c *Consensus) ApplyUnclePenalty(weight types.Difficulty) (uncleWeight, unclePenalty types.Difficulty)
- func (c *Consensus) CalculateId() types.Hash
- func (c *Consensus) CalculateSideChainIdFromBlobs(mainBlob, sideBlob []byte) (result types.Hash)
- func (c *Consensus) CalculateSideTemplateId(share *PoolBlock) (result types.Hash)
- func (c *Consensus) CalculateSideTemplateIdPreAllocated(share *PoolBlock, buf []byte) (result types.Hash)
- func (c *Consensus) DefaultPort() uint16
- func (c *Consensus) GetHasher() randomx.Hasher
- func (c *Consensus) InitHasher(n int, flags ...randomx.Flag) error
- func (c *Consensus) IsDefault() bool
- func (c *Consensus) IsMini() bool
- func (c *Consensus) SeedNode() string
- type ConsensusProvider
- type DerivationCache
- type DerivationCacheInterface
- type DifficultyData
- type FakeServer
- func (s *FakeServer) Broadcast(block *PoolBlock)
- func (s *FakeServer) ClearCachedBlocks()
- func (s *FakeServer) ClientRPC() *client.Client
- func (s *FakeServer) Consensus() *Consensus
- func (s *FakeServer) Context() context.Context
- func (s *FakeServer) GetBlob(key []byte) (blob []byte, err error)
- func (s *FakeServer) GetChainMainByHash(hash types.Hash) *ChainMain
- func (s *FakeServer) GetChainMainByHeight(height uint64) *ChainMain
- func (s *FakeServer) GetChainMainTip() *ChainMain
- func (s *FakeServer) GetDifficultyByHeight(height uint64) types.Difficulty
- func (s *FakeServer) GetMinerDataTip() *p2pooltypes.MinerData
- func (s *FakeServer) GetMinimalBlockHeaderByHash(hash types.Hash) *mainblock.Header
- func (s *FakeServer) GetMinimalBlockHeaderByHeight(height uint64) *mainblock.Header
- func (s *FakeServer) RemoveBlob(key []byte) (err error)
- func (s *FakeServer) SetBlob(key, blob []byte) (err error)
- func (s *FakeServer) Store(block *PoolBlock)
- func (s *FakeServer) SubmitBlock(block *mainblock.Block)
- func (s *FakeServer) UpdateBlockFound(data *ChainMain, block *PoolBlock)
- func (s *FakeServer) UpdateTip(tip *PoolBlock)
- type FullId
- type GetByMainHeightFunc
- type GetByMainIdFunc
- type GetBySideHeightFunc
- type GetByTemplateIdFunc
- type GetChainMainByHashFunc
- type HardFork
- type IterationCache
- type NetworkType
- type NilDerivationCache
- type P2PoolInterface
- type PoolBlock
- func (b *PoolBlock) AppendBinaryFlags(preAllocatedBuf []byte, pruned, compact bool) (buf []byte, err error)
- func (b *PoolBlock) BufferLength() int
- func (b *PoolBlock) CalculateFullId(consensus *Consensus) FullId
- func (b *PoolBlock) CalculateShareVersion(consensus *Consensus) ShareVersion
- func (b *PoolBlock) CalculateTransactionPrivateKeySeed() types.Hash
- func (b *PoolBlock) CoinbaseExtra(tag CoinbaseExtraTag) []byte
- func (b *PoolBlock) CoinbaseId() types.Hash
- func (b *PoolBlock) ExtraNonce() uint32
- func (b *PoolBlock) FillPrivateKeys(derivationCache DerivationCacheInterface)
- func (b *PoolBlock) FillTransactionParentIndices(parent *PoolBlock) bool
- func (b *PoolBlock) FillTransactionsFromTransactionParentIndices(parent *PoolBlock) error
- func (b *PoolBlock) FromCompactReader(consensus *Consensus, derivationCache DerivationCacheInterface, ...) (err error)
- func (b *PoolBlock) FromReader(consensus *Consensus, derivationCache DerivationCacheInterface, ...) (err error)
- func (b *PoolBlock) FullId() FullId
- func (b *PoolBlock) GetAddress() address.PackedAddress
- func (b *PoolBlock) GetPrivateKeySeed() types.Hash
- func (b *PoolBlock) GetTransactionOutputType() uint8
- func (b *PoolBlock) IsProofHigherThanDifficulty(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) bool
- func (b *PoolBlock) IsProofHigherThanDifficultyWithError(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) (bool, error)
- func (b *PoolBlock) IsProofHigherThanMainDifficulty(hasher randomx.Hasher, difficultyFunc mainblock.GetDifficultyByHeightFunc, ...) bool
- func (b *PoolBlock) IsProofHigherThanMainDifficultyWithError(hasher randomx.Hasher, difficultyFunc mainblock.GetDifficultyByHeightFunc, ...) (bool, error)
- func (b *PoolBlock) MainDifficulty(f mainblock.GetDifficultyByHeightFunc) types.Difficulty
- func (b *PoolBlock) MainId() types.Hash
- func (b *PoolBlock) MarshalBinary() ([]byte, error)
- func (b *PoolBlock) MarshalBinaryFlags(pruned, compact bool) ([]byte, error)
- func (b *PoolBlock) NeedsCompactTransactionFilling() bool
- func (b *PoolBlock) NeedsPreProcess() bool
- func (b *PoolBlock) PowHash(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) types.Hash
- func (b *PoolBlock) PowHashWithError(hasher randomx.Hasher, f mainblock.GetSeedByHeightFunc) (powHash types.Hash, err error)
- func (b *PoolBlock) PreProcessBlock(consensus *Consensus, derivationCache DerivationCacheInterface, ...) (missingBlocks []types.Hash, err error)
- func (b *PoolBlock) PreProcessBlockWithOutputs(getTemplateById GetByTemplateIdFunc, ...) (missingBlocks []types.Hash, err error)
- func (b *PoolBlock) ShareVersion() ShareVersion
- func (b *PoolBlock) ShareVersionSignaling() ShareVersion
- func (b *PoolBlock) SideTemplateId(consensus *Consensus) types.Hash
- func (b *PoolBlock) UnmarshalBinary(consensus *Consensus, derivationCache DerivationCacheInterface, data []byte) error
- type PoolBlockWindowAddWeightFunc
- type PoolBlockWindowSlot
- type PreAllocatedSharesPool
- type Share
- type ShareVersion
- type Shares
- type SideChain
- func (c *SideChain) AddPoolBlock(block *PoolBlock) (err error)
- func (c *SideChain) AddPoolBlockExternal(block *PoolBlock) (missingBlocks []types.Hash, err error, ban bool)
- func (c *SideChain) BlockSeen(block *PoolBlock) bool
- func (c *SideChain) BlockUnsee(block *PoolBlock)
- func (c *SideChain) Consensus() *Consensus
- func (c *SideChain) DerivationCache() *DerivationCache
- func (c *SideChain) Difficulty() types.Difficulty
- func (c *SideChain) GetChainTip() *PoolBlock
- func (c *SideChain) GetDifficulty(tip *PoolBlock) (difficulty types.Difficulty, verifyError, invalidError error)
- func (c *SideChain) GetHighestKnownTip() *PoolBlock
- func (c *SideChain) GetMissingBlocks() []types.Hash
- func (c *SideChain) GetParent(block *PoolBlock) *PoolBlock
- func (c *SideChain) GetPoolBlockByTemplateId(id types.Hash) *PoolBlock
- func (c *SideChain) GetPoolBlockCount() int
- func (c *SideChain) GetPoolBlocksByHeight(height uint64) []*PoolBlock
- func (c *SideChain) GetPoolBlocksFromTip(id types.Hash) (chain, uncles UniquePoolBlockSlice)
- func (c *SideChain) GetPoolBlocksFromTipWithDepth(id types.Hash, depth uint64) (chain, uncles UniquePoolBlockSlice)
- func (c *SideChain) GetPossibleUncles(tip *PoolBlock, forHeight uint64) (uncles []types.Hash)
- func (c *SideChain) IsLongerChain(block, candidate *PoolBlock) (isLonger, isAlternative bool)
- func (c *SideChain) LastUpdated() uint64
- func (c *SideChain) PreCalcFinished() bool
- func (c *SideChain) PreprocessBlock(block *PoolBlock) (missingBlocks []types.Hash, err error)
- func (c *SideChain) Server() P2PoolInterface
- func (c *SideChain) WatchMainChainBlock(mainData *ChainMain, possibleId types.Hash)
- type SideData
- func (b *SideData) AppendBinary(preAllocatedBuf []byte, version ShareVersion) (buf []byte, err error)
- func (b *SideData) BufferLength() int
- func (b *SideData) FromReader(reader utils.ReaderAndByteReader, version ShareVersion) (err error)
- func (b *SideData) MarshalBinary(version ShareVersion) (buf []byte, err error)
- func (b *SideData) UnmarshalBinary(data []byte, version ShareVersion) error
- type UniquePoolBlockSlice
Constants ¶
const ( BlockSaveOptionTemplate = 1 << 0 BlockSaveOptionDeterministicPrivateKeySeed = 1 << 1 BlockSaveOptionDeterministicBlobs = 1 << 2 BlockSaveOptionUncles = 1 << 3 BlockSaveFieldSizeInBits = 8 BlockSaveOffsetAddress = BlockSaveFieldSizeInBits BlockSaveOffsetMainFields = BlockSaveFieldSizeInBits * 2 )
const ( SideCoinbasePublicKey = transaction.TxExtraTagPubKey SideExtraNonce = transaction.TxExtraTagNonce SideTemplateId = transaction.TxExtraTagMergeMining )
const BlockSaveEpochSize = 32
BlockSaveEpochSize could be up to 256?
const FullIdSize = int(types.HashSize + unsafe.Sizeof(uint32(0)) + SideExtraNonceSize)
const LargestMinimumDifficulty = 1000000000
const PoolBlockMaxTemplateSize = 128*1024 - (1 + 4)
PoolBlockMaxTemplateSize Max P2P message size (128 KB) minus BLOCK_RESPONSE header (5 bytes)
const SideExtraNonceMaxSize = SideExtraNonceSize + 10
const SideExtraNonceSize = 4
const SmallestMinimumDifficulty = 100000
const (
UncleBlockDepth = 3
)
Variables ¶
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}}
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 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 SplitRewardAllocate ¶
Types ¶
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 (*Consensus) ApplyUnclePenalty ¶
func (c *Consensus) ApplyUnclePenalty(weight types.Difficulty) (uncleWeight, unclePenalty types.Difficulty)
ApplyUnclePenalty Applies UnclePenalty efficiently
func (*Consensus) CalculateId ¶
func (*Consensus) CalculateSideChainIdFromBlobs ¶
func (*Consensus) CalculateSideTemplateId ¶
func (*Consensus) CalculateSideTemplateIdPreAllocated ¶
func (*Consensus) DefaultPort ¶
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 (*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) 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 (FullId) ExtraNonce ¶
func (FullId) TemplateId ¶
type GetByMainHeightFunc ¶
type GetByMainHeightFunc func(height uint64) UniquePoolBlockSlice
type GetByMainIdFunc ¶
type GetBySideHeightFunc ¶
type GetBySideHeightFunc func(height uint64) UniquePoolBlockSlice
type GetByTemplateIdFunc ¶
type GetChainMainByHashFunc ¶
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 ¶
type IterationCache ¶
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 (*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:"-"` // contains filtered or unexported fields }
func NewShareFromExportedBytes ¶
func NewShareFromExportedBytes(buf []byte, consensus *Consensus, cacheInterface DerivationCacheInterface) (*PoolBlock, error)
NewShareFromExportedBytes Deprecated
func (*PoolBlock) AppendBinaryFlags ¶
func (*PoolBlock) BufferLength ¶
func (*PoolBlock) CalculateFullId ¶
func (*PoolBlock) CalculateShareVersion ¶
func (b *PoolBlock) CalculateShareVersion(consensus *Consensus) ShareVersion
func (*PoolBlock) CalculateTransactionPrivateKeySeed ¶
func (*PoolBlock) CoinbaseExtra ¶
func (b *PoolBlock) CoinbaseExtra(tag CoinbaseExtraTag) []byte
func (*PoolBlock) CoinbaseId ¶
func (*PoolBlock) ExtraNonce ¶
func (*PoolBlock) FillPrivateKeys ¶
func (b *PoolBlock) FillPrivateKeys(derivationCache DerivationCacheInterface)
func (*PoolBlock) FillTransactionParentIndices ¶
func (*PoolBlock) FillTransactionsFromTransactionParentIndices ¶
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) GetAddress ¶
func (b *PoolBlock) GetAddress() address.PackedAddress
func (*PoolBlock) GetPrivateKeySeed ¶
func (*PoolBlock) GetTransactionOutputType ¶
func (*PoolBlock) IsProofHigherThanDifficulty ¶
func (*PoolBlock) IsProofHigherThanDifficultyWithError ¶
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 (b *PoolBlock) MainDifficulty(f mainblock.GetDifficultyByHeightFunc) types.Difficulty
func (*PoolBlock) MarshalBinary ¶
func (*PoolBlock) MarshalBinaryFlags ¶
func (*PoolBlock) NeedsCompactTransactionFilling ¶
func (*PoolBlock) NeedsPreProcess ¶
func (*PoolBlock) PowHashWithError ¶
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 (*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 ShareVersion ¶
type ShareVersion uint8
const ()
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 ¶
type SideChain ¶
type SideChain struct {
// contains filtered or unexported fields
}
func NewSideChain ¶
func NewSideChain(server P2PoolInterface) *SideChain
func (*SideChain) AddPoolBlock ¶
func (*SideChain) AddPoolBlockExternal ¶
func (*SideChain) BlockUnsee ¶
func (*SideChain) DerivationCache ¶
func (c *SideChain) DerivationCache() *DerivationCache
func (*SideChain) Difficulty ¶
func (c *SideChain) Difficulty() types.Difficulty
func (*SideChain) GetChainTip ¶
func (*SideChain) GetDifficulty ¶
func (c *SideChain) GetDifficulty(tip *PoolBlock) (difficulty types.Difficulty, verifyError, invalidError error)
func (*SideChain) GetHighestKnownTip ¶
func (*SideChain) GetMissingBlocks ¶
func (*SideChain) GetPoolBlockByTemplateId ¶
func (*SideChain) GetPoolBlockCount ¶
func (*SideChain) GetPoolBlocksByHeight ¶
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 (*SideChain) IsLongerChain ¶
func (*SideChain) LastUpdated ¶
func (*SideChain) PreCalcFinished ¶
func (*SideChain) PreprocessBlock ¶
func (*SideChain) Server ¶
func (c *SideChain) Server() P2PoolInterface
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 (*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) GetHeight ¶
func (s UniquePoolBlockSlice) GetHeight(height uint64) (result UniquePoolBlockSlice)