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 LoadSideChainTestData(c *SideChain, reader io.Reader, patchedBlocks ...[]byte) error
- 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
- func (c *Consensus) SeedNodes() []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 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) FastSideTemplateId(consensus *Consensus) types.Hash
- func (b *PoolBlock) FillPrivateKeys(derivationCache DerivationCacheInterface)
- func (b *PoolBlock) FillTransactionParentIndices(consensus *Consensus, parent *PoolBlock) bool
- func (b *PoolBlock) FillTransactionsFromTransactionParentIndices(consensus *Consensus, 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(consensus *Consensus) 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) MergeMiningTag() merge_mining.Tag
- 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(consensus *Consensus, 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 PoolBlockReceptionMetadata
- 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) GetPoolBlockByMerkleRoot(id types.Hash) *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() time.Time
- func (c *SideChain) PoolBlockExternalVerify(block *PoolBlock) (missingBlocks []types.Hash, err error, ban bool)
- 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(version ShareVersion) (size 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 SideDataExtraBuffer
- type UniquePoolBlockSlice
Constants ¶
const (ShareVersion_V1 ShareVersion_V2 ShareVersion_V3 )
const ( SideCoinbasePublicKey = transaction.TxExtraTagPubKey SideExtraNonce = transaction.TxExtraTagNonce // SideIdentifierHash Depending on version, this can be a PoolBlock TemplateId or Merkle Root Hash SideIdentifierHash = transaction.TxExtraTagMergeMining )
const FullIdSize = int(types.HashSize + unsafe.Sizeof(uint32(0)) + SideExtraNonceSize)
const LargestMinimumDifficulty = 1000000000
const MaxMerkleProofSize = 8
MaxMerkleProofSize Maximum number of proofs in field TODO: generate this from merkle proof parameters and slots?
const PoolBlockMaxSideChainHeight = 31556952000
PoolBlockMaxSideChainHeight 1000 years at 1 block/second. It should be enough for any normal use.
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}, }
var PoolBlockMaxCumulativeDifficulty = types.NewDifficulty(13019633956666736640, 1710)
PoolBlockMaxCumulativeDifficulty 1000 years at 1 TH/s. It should be enough for any normal use.
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 LoadSideChainTestData ¶ added in v3.2.0
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"` // Extra additional string to add for testing usually Extra string `json:"extra,omitempty"` // HardFork optional hardfork information for p2pool // If empty it will be filled with the default hardfork list to the corresponding NetworkType // Note: this is not supported by p2pool itself HardForks []monero.HardFork `json:"hard_forks,omitempty"` Id types.Hash `json:"id"` // contains filtered or unexported fields }
func NewConsensus ¶
func NewConsensus(networkType NetworkType, poolName, poolPassword, extra 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 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) MustAddressNetwork ¶ added in v3.5.0
func (n NetworkType) MustAddressNetwork() uint8
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:"-"` Metadata PoolBlockReceptionMetadata `json:"metadata"` // contains filtered or unexported fields }
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) FastSideTemplateId ¶ added in v3.4.0
FastSideTemplateId Returns SideTemplateId from either coinbase extra tags or pruned data, or main block if not pruned
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) MergeMiningTag ¶ added in v3.4.0
func (b *PoolBlock) MergeMiningTag() merge_mining.Tag
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(consensus *Consensus, 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 PoolBlockReceptionMetadata ¶ added in v3.6.0
type PoolBlockReceptionMetadata struct { // LocalTime Moment the block was received from a source LocalTime time.Time `json:"local_time,omitempty"` // AddressPort The address and port of the peer who broadcasted or sent us this block // If the peer specified a listen port, the port will be that instead of current connection one AddressPort netip.AddrPort `json:"address_port,omitempty"` // PeerId The peer id of the peer who broadcasted or sent us this block PeerId uint64 `json:"peer_id,omitempty"` SoftwareId uint32 `json:"software_id"` SoftwareVersion uint32 `json:"software_version"` }
func (*PoolBlockReceptionMetadata) MarshalBinary ¶ added in v3.6.2
func (m *PoolBlockReceptionMetadata) MarshalBinary() ([]byte, error)
func (*PoolBlockReceptionMetadata) UnmarshalBinary ¶ added in v3.6.2
func (m *PoolBlockReceptionMetadata) UnmarshalBinary(buf []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
func P2PoolShareVersion ¶
func P2PoolShareVersion(consensus *Consensus, timestamp uint64) ShareVersion
P2PoolShareVersion Different miners can have different timestamps, so a temporary mix of old and new blocks is allowed
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) GetPoolBlockByMerkleRoot ¶ added in v3.4.0
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) PoolBlockExternalVerify ¶ added in v3.4.0
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 Template Id of the parent of this share, or zero if genesis Parent types.Hash `json:"parent"` // Uncles List of Template Ids of the uncles this share contains Uncles []types.Hash `json:"uncles,omitempty"` Height uint64 `json:"height"` Difficulty types.Difficulty `json:"difficulty"` CumulativeDifficulty types.Difficulty `json:"cumulative_difficulty"` // MerkleProof Merkle proof for merge mining, available in ShareVersion ShareVersion_V3 and above MerkleProof crypto.MerkleProof `json:"merkle_proof,omitempty"` // ExtraBuffer Arbitrary extra data, available in ShareVersion ShareVersion_V2 and above ExtraBuffer SideDataExtraBuffer `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(version ShareVersion) (size 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 SideDataExtraBuffer ¶ added in v3.2.0
type SideDataExtraBuffer 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"` }
type UniquePoolBlockSlice ¶
type UniquePoolBlockSlice []*PoolBlock
func (UniquePoolBlockSlice) Get ¶
func (s UniquePoolBlockSlice) Get(consensus *Consensus, id types.Hash) *PoolBlock
func (UniquePoolBlockSlice) GetHeight ¶
func (s UniquePoolBlockSlice) GetHeight(height uint64) (result UniquePoolBlockSlice)