Documentation
¶
Index ¶
- Constants
- Variables
- func BlocksInPPLNSWindow(tip *PoolBlock, consensus *Consensus, ...) (bottomHeight uint64, err error)
- func CalculateEnoteCarrot(derivationCache DerivationCacheInterface, ...) (enote *carrot.CoinbaseEnoteV1)
- func CalculateOutputCarrot(enote *carrot.CoinbaseEnoteV1, txType uint8, outputIndex uint64) transaction.Output
- func CalculateOutputCryptonote(derivationCache DerivationCacheInterface, txType uint8, ...) transaction.Output
- func CalculateOutputs(block *PoolBlock, consensus *Consensus, ...) (outputs transaction.Outputs, pubs []curve25519.PublicKeyBytes, ...)
- func CalculateTransactionPrivateKeySeed(main, side []byte) (result types.Hash)
- func GetDeterministicTransactionPrivateKey(out *curve25519.Scalar, seed, previousMoneroId types.Hash) *curve25519.Scalar
- 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 NextDifficulty(consensus *Consensus, timestamps []uint64, difficultyData []DifficultyData) (nextDifficulty types.Difficulty, err error)
- func ShuffleSequence(majorVersion uint8, shareVersion ShareVersion, privateKeySeed types.Hash, ...)
- func ShuffleShares[T any](shares []T, majorVersion uint8, shareVersion ShareVersion, ...)
- 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) InitTestHasher() error
- func (c *Consensus) IsDefault() bool
- func (c *Consensus) IsMini() bool
- func (c *Consensus) IsNano() bool
- func (c *Consensus) SeedNode() string
- func (c *Consensus) SeedNodes() []string
- func (c *Consensus) TorNodes() []p2pooltypes.OnionAddressV3
- type ConsensusProvider
- type DerivationCache
- func (d *DerivationCache) Clear()
- func (d *DerivationCache) GetCarrotCoinbaseEnote(a *address.PackedAddressWithSubaddress, seed types.Hash, ...) *carrot.CoinbaseEnoteV1
- func (d *DerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair[curve25519.VarTimeOperations]
- func (d *DerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, txKey curve25519.PrivateKeyBytes, ...) (curve25519.PublicKeyBytes, uint8)
- type DerivationCacheInterface
- type DifficultyData
- type FakeServer
- func (s *FakeServer) Broadcast(block *PoolBlock)
- func (s *FakeServer) BroadcastMoneroBlock(block *mainblock.Block)
- func (s *FakeServer) ClearCachedBlocks()
- func (s *FakeServer) ClientRPC() *client.Client
- func (s *FakeServer) Consensus() *Consensus
- func (s *FakeServer) Context() context.Context
- func (s *FakeServer) DownloadMinimalBlockHeaders(currentHeight uint64) error
- 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) SideChain() *SideChain
- 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 MergeMiningExtra
- func (d MergeMiningExtra) BufferLength() (size int)
- func (d MergeMiningExtra) Get(chainId types.Hash) ([]byte, bool)
- func (d MergeMiningExtra) Merge(other MergeMiningExtra) MergeMiningExtra
- func (d MergeMiningExtra) Set(chainId types.Hash, data []byte) MergeMiningExtra
- func (d MergeMiningExtra) Sort()
- type MergeMiningExtraData
- type NetworkType
- type NilDerivationCache
- func (d *NilDerivationCache) Clear()
- func (d *NilDerivationCache) GetCarrotCoinbaseEnote(a *address.PackedAddressWithSubaddress, seed types.Hash, ...) *carrot.CoinbaseEnoteV1
- func (d *NilDerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair[curve25519.VarTimeOperations]
- func (d *NilDerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, _ curve25519.PrivateKeyBytes, ...) (curve25519.PublicKeyBytes, uint8)
- 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) CoinbasePublicKeys() (result []curve25519.PublicKeyBytes)
- 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.PackedAddressWithSubaddress
- func (b *PoolBlock) GetConsensusPackedAddress(targetMajorVersion uint8) address.PackedAddressWithSubaddress
- func (b *PoolBlock) GetMergeMineExtraSubaddress() *address.PackedAddressWithSubaddress
- func (b *PoolBlock) GetOnionAddressV3() *p2pooltypes.OnionAddressV3
- func (b *PoolBlock) GetPayoutAddress(networkType NetworkType) *address.Address
- 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) NeedsPostProcess() 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
- func (b *PoolBlock) UnmarshalJSON(buf []byte) (err error)
- type PoolBlockReceptionMetadata
- type PoolBlockWindowAddWeightFunc
- type PoolBlockWindowSlot
- type PreAllocatedSharesPool
- type PruneMode
- 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 []*PoolBlock)
- func (c *SideChain) GetPruneMode() PruneMode
- 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) SetPruneMode(mode PruneMode) error
- func (c *SideChain) WatchMainChainBlock(mainData *ChainMain, possibleId types.Hash)
- type SideData
- func (b *SideData) AppendBinary(preAllocatedBuf []byte, majorVersion uint8, version ShareVersion) (buf []byte, err error)
- func (b *SideData) BufferLength(majorVersion uint8, version ShareVersion) (size int)
- func (b *SideData) FromReader(reader utils.ReaderAndByteReader, majorVersion uint8, version ShareVersion) (err error)
- func (b *SideData) MarshalBinary(majorVersion uint8, version ShareVersion) (buf []byte, err error)
- func (b *SideData) UnmarshalBinary(data []byte, majorVersion uint8, version ShareVersion) error
- type SideDataExtraBuffer
- type UniquePoolBlockSlice
Constants ¶
const ( UncleBlockDepth = 3 MaxTxOutputReward = (1 << 56) - 1 )
const ( ShareVersion_V1 ShareVersion_V2 ShareVersion_V3 )
const ( 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 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
Variables ¶
var ConsensusDefault = &Consensus{ NetworkType: NetworkMainnet, PoolName: "mainnet test 2", TargetBlockTime: 10, MinimumDifficulty: 100000, ChainWindowSize: 2160, UnclePenalty: 20, HardForks: p2poolMainNetHardForks, MoneroHardForks: monero.NetworkHardFork(monero.MainNetwork), 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, MoneroHardForks: monero.NetworkHardFork(monero.MainNetwork), 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 ConsensusNano = &Consensus{ NetworkType: NetworkMainnet, PoolName: "nano", TargetBlockTime: 30, MinimumDifficulty: 100000, ChainWindowSize: 2160, UnclePenalty: 10, HardForks: p2poolMainNetHardForks, MoneroHardForks: monero.NetworkHardFork(monero.MainNetwork), Id: types.Hash{171, 248, 206, 148, 210, 226, 114, 99, 250, 145, 221, 96, 13, 216, 23, 63, 104, 53, 129, 168, 244, 80, 141, 138, 157, 250, 50, 54, 37, 189, 5, 89}, }
var ErrNoDifficulty = errors.New("could not get difficulty")
var ErrNoMainDifficulty = errors.New("could not get main difficulty")
var ErrPanic = errors.New("panic while processing")
var ErrParentInvalid = errors.New("parent is invalid")
var ErrParentNotVerified = errors.New("parent is not verified")
var ExtraChainKeyOnionAddressV3 = crypto.Keccak256([]byte("onion_address_v3"))
ExtraChainKeyOnionAddressV3 Format PublicKeyBytes (PUBKEY) | varint(0) | varint(0) https://spec.torproject.org/rend-spec/encoding-onion-addresses.html
var ExtraChainKeySubaddressViewPub = crypto.Keccak256([]byte("subaddress_viewpub"))
ExtraChainKeySubaddressViewPub Format PublicKeyBytes (subaddress view pub) | varint(0) | varint(0)
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 CalculateEnoteCarrot ¶
func CalculateEnoteCarrot(derivationCache DerivationCacheInterface, a *address.PackedAddressWithSubaddress, seed types.Hash, blockIndex, amount uint64) (enote *carrot.CoinbaseEnoteV1)
func CalculateOutputCarrot ¶
func CalculateOutputCarrot(enote *carrot.CoinbaseEnoteV1, txType uint8, outputIndex uint64) transaction.Output
func CalculateOutputCryptonote ¶
func CalculateOutputCryptonote(derivationCache DerivationCacheInterface, txType uint8, a *address.PackedAddress, txPrivateKey curve25519.PrivateKeyBytes, txPrivateKeyScalar *curve25519.Scalar, outputIndex, amount uint64) transaction.Output
func CalculateOutputs ¶
func CalculateOutputs(block *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, derivationCache DerivationCacheInterface, preAllocatedShares Shares, preAllocatedRewards []uint64) (outputs transaction.Outputs, pubs []curve25519.PublicKeyBytes, bottomHeight uint64, err error)
func GetDeterministicTransactionPrivateKey ¶
func GetDeterministicTransactionPrivateKey(out *curve25519.Scalar, seed, previousMoneroId types.Hash) *curve25519.Scalar
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 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(majorVersion uint8, 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, majorVersion uint8, 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"`
// HardForks optional sidechain 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"`
// HardForks optional mainchain hardfork information
// If empty it will be filled with the default hardfork list to the corresponding NetworkType
// Note: this is not supported by p2pool itself
MoneroHardForks []monero.HardFork `json:"monero_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 ¶
func (*Consensus) InitTestHasher ¶
func (*Consensus) TorNodes ¶
func (c *Consensus) TorNodes() []p2pooltypes.OnionAddressV3
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 NewDerivationNilCache ¶
func NewDerivationNilCache() *DerivationCache
func (*DerivationCache) Clear ¶
func (d *DerivationCache) Clear()
func (*DerivationCache) GetCarrotCoinbaseEnote ¶
func (d *DerivationCache) GetCarrotCoinbaseEnote(a *address.PackedAddressWithSubaddress, seed types.Hash, blockIndex, amount uint64) *carrot.CoinbaseEnoteV1
func (*DerivationCache) GetDeterministicTransactionKey ¶
func (d *DerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair[curve25519.VarTimeOperations]
func (*DerivationCache) GetEphemeralPublicKey ¶
func (d *DerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, txKey curve25519.PrivateKeyBytes, txKeyScalar *curve25519.Scalar, outputIndex uint64) (curve25519.PublicKeyBytes, uint8)
type DerivationCacheInterface ¶
type DerivationCacheInterface interface {
GetEphemeralPublicKey(a *address.PackedAddress, txKeySlice curve25519.PrivateKeyBytes, txKeyScalar *curve25519.Scalar, outputIndex uint64) (curve25519.PublicKeyBytes, uint8)
GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair[curve25519.VarTimeOperations]
GetCarrotCoinbaseEnote(a *address.PackedAddressWithSubaddress, seed types.Hash, blockIndex, amount uint64) *carrot.CoinbaseEnoteV1
}
type DifficultyData ¶
type DifficultyData struct {
// contains filtered or unexported fields
}
type FakeServer ¶
type FakeServer struct {
Tip *PoolBlock
// contains filtered or unexported fields
}
func GetFakeTestServer ¶
func GetFakeTestServer(consensus *Consensus) *FakeServer
func GetFakeTestServerWithRPC ¶
func GetFakeTestServerWithRPC(consensus *Consensus, rpcClient *client.Client) *FakeServer
func (*FakeServer) Broadcast ¶
func (s *FakeServer) Broadcast(block *PoolBlock)
func (*FakeServer) BroadcastMoneroBlock ¶
func (s *FakeServer) BroadcastMoneroBlock(block *mainblock.Block)
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) DownloadMinimalBlockHeaders ¶
func (s *FakeServer) DownloadMinimalBlockHeaders(currentHeight uint64) 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) SideChain ¶
func (s *FakeServer) SideChain() *SideChain
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 MergeMiningExtra ¶
type MergeMiningExtra []MergeMiningExtraData
func (MergeMiningExtra) BufferLength ¶
func (d MergeMiningExtra) BufferLength() (size int)
func (MergeMiningExtra) Merge ¶
func (d MergeMiningExtra) Merge(other MergeMiningExtra) MergeMiningExtra
func (MergeMiningExtra) Set ¶
func (d MergeMiningExtra) Set(chainId types.Hash, data []byte) MergeMiningExtra
func (MergeMiningExtra) Sort ¶
func (d MergeMiningExtra) Sort()
type MergeMiningExtraData ¶
type MergeMiningExtraData struct {
ChainId types.Hash `json:"chain_id"`
// Data has merge mining hash and difficulty (two varints for low and high 64 bits) in the beginning,
// the rest is arbitrary and depends on the merge mined chain's requirements
Data types.Bytes `json:"data,omitempty"`
}
func (MergeMiningExtraData) BufferLength ¶
func (d MergeMiningExtraData) BufferLength() (size int)
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 ¶
func (n NetworkType) MustAddressNetwork() uint8
func (NetworkType) String ¶
func (n NetworkType) String() string
func (NetworkType) SubaddressNetwork ¶
func (n NetworkType) SubaddressNetwork() (uint8, error)
func (*NetworkType) UnmarshalJSON ¶
func (n *NetworkType) UnmarshalJSON(b []byte) error
type NilDerivationCache ¶
type NilDerivationCache struct {
}
func (*NilDerivationCache) Clear ¶
func (d *NilDerivationCache) Clear()
func (*NilDerivationCache) GetCarrotCoinbaseEnote ¶
func (d *NilDerivationCache) GetCarrotCoinbaseEnote(a *address.PackedAddressWithSubaddress, seed types.Hash, blockIndex, amount uint64) *carrot.CoinbaseEnoteV1
func (*NilDerivationCache) GetDeterministicTransactionKey ¶
func (d *NilDerivationCache) GetDeterministicTransactionKey(seed types.Hash, prevId types.Hash) *crypto.KeyPair[curve25519.VarTimeOperations]
func (*NilDerivationCache) GetEphemeralPublicKey ¶
func (d *NilDerivationCache) GetEphemeralPublicKey(a *address.PackedAddress, _ curve25519.PrivateKeyBytes, txKeyScalar *curve25519.Scalar, outputIndex uint64) (curve25519.PublicKeyBytes, uint8)
type P2PoolInterface ¶
type P2PoolInterface interface {
ConsensusProvider
Cache
Context() context.Context
UpdateTip(tip *PoolBlock)
BroadcastMoneroBlock(block *mainblock.Block)
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:"-"`
Thinned 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) CoinbasePublicKeys ¶
func (b *PoolBlock) CoinbasePublicKeys() (result []curve25519.PublicKeyBytes)
func (*PoolBlock) ExtraNonce ¶
func (*PoolBlock) FastSideTemplateId ¶
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.PackedAddressWithSubaddress
func (*PoolBlock) GetConsensusPackedAddress ¶
func (b *PoolBlock) GetConsensusPackedAddress(targetMajorVersion uint8) address.PackedAddressWithSubaddress
GetConsensusPackedAddress Gets the address to use for sidechain share weight calculation dependent on target major version
func (*PoolBlock) GetMergeMineExtraSubaddress ¶
func (b *PoolBlock) GetMergeMineExtraSubaddress() *address.PackedAddressWithSubaddress
func (*PoolBlock) GetOnionAddressV3 ¶
func (b *PoolBlock) GetOnionAddressV3() *p2pooltypes.OnionAddressV3
func (*PoolBlock) GetPayoutAddress ¶
func (b *PoolBlock) GetPayoutAddress(networkType NetworkType) *address.Address
GetPayoutAddress Special function that checks if a subaddress has been specified, on the right network Not consensus
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 ¶
func (b *PoolBlock) MergeMiningTag() merge_mining.Tag
func (*PoolBlock) NeedsCompactTransactionFilling ¶
func (*PoolBlock) NeedsPostProcess ¶
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, pubs []curve25519.PublicKeyBytes, bottomHeight uint64, err error)) (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
func (*PoolBlock) UnmarshalJSON ¶
type PoolBlockReceptionMetadata ¶
type PoolBlockReceptionMetadata struct {
// LocalTime Moment the block was received from a source
LocalTime time.Time `json:"local_time"`
// 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"`
// PeerId The peer id of the peer who broadcasted or sent us this block
PeerId uint64 `json:"peer_id,omitzero"`
SoftwareId uint32 `json:"software_id"`
SoftwareVersion uint32 `json:"software_version"`
}
func (*PoolBlockReceptionMetadata) MarshalBinary ¶
func (m *PoolBlockReceptionMetadata) MarshalBinary() ([]byte, error)
func (*PoolBlockReceptionMetadata) UnmarshalBinary ¶
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 PruneMode ¶
type PruneMode int
PruneMode The mode on how to prune blocks within SideChain Can be set before any blocks are added, or, a greater value in runtime. For example, can go from PruneModeNone to PruneModeDefault, or PruneModeDefault to PruneModeThin
const ( // PruneModeNone Never prune old blocks // Do not use on production PruneModeNone PruneMode = -1 // PruneModeDefault The default, keeps all blocks required to do full verification. // Matches upstream p2pool behavior PruneModeDefault PruneMode = 0 // PruneModeThin Prunes blocks like PruneModeDefault, except unnecessary data is removed from all but a few on top. Useful to reduce memory usage // These pruned blocks cannot be sent to clients // TODO: prune crypto cache as well? PruneModeThin PruneMode = 1 )
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
func (ShareVersion) Supports ¶
func (v ShareVersion) Supports(majorVersion uint8) bool
type Shares ¶
type Shares []*Share
func GetShares ¶
func GetShares(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, preAllocatedShares Shares) (shares Shares, bottomHeight uint64, err error)
func GetSharesOrdered ¶
func GetSharesOrdered(tip *PoolBlock, consensus *Consensus, difficultyByHeight block.GetDifficultyByHeightFunc, getByTemplateId GetByTemplateIdFunc, preAllocatedShares Shares) (shares Shares, bottomHeight uint64, err error)
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 ¶
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) GetPruneMode ¶
func (*SideChain) IsLongerChain ¶
func (*SideChain) LastUpdated ¶
func (*SideChain) PoolBlockExternalVerify ¶
func (*SideChain) PreCalcFinished ¶
func (*SideChain) PreprocessBlock ¶
func (*SideChain) Server ¶
func (c *SideChain) Server() P2PoolInterface
func (*SideChain) SetPruneMode ¶
type SideData ¶
type SideData struct {
PublicKey address.PackedAddress `json:"public_key"`
IsSubaddress bool `json:"is_subaddress,omitempty"`
CoinbasePrivateKeySeed types.Hash `json:"coinbase_private_key_seed,omitzero"`
// CoinbasePrivateKey filled or calculated on decoding,
CoinbasePrivateKey curve25519.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"`
// MergeMiningExtra vector of (chain ID, chain data) pairs
// Chain data format is arbitrary and depends on the merge mined chain's requirements
MergeMiningExtra MergeMiningExtra `json:"merge_mining_extra,omitempty"`
// ExtraBuffer Arbitrary extra data, available in ShareVersion ShareVersion_V2 and above
ExtraBuffer SideDataExtraBuffer `json:"extra_buffer"`
}
func (*SideData) AppendBinary ¶
func (*SideData) BufferLength ¶
func (b *SideData) BufferLength(majorVersion uint8, version ShareVersion) (size int)
func (*SideData) FromReader ¶
func (b *SideData) FromReader(reader utils.ReaderAndByteReader, majorVersion uint8, version ShareVersion) (err error)
func (*SideData) MarshalBinary ¶
func (b *SideData) MarshalBinary(majorVersion uint8, version ShareVersion) (buf []byte, err error)
func (*SideData) UnmarshalBinary ¶
func (b *SideData) UnmarshalBinary(data []byte, majorVersion uint8, version ShareVersion) error
type SideDataExtraBuffer ¶
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 LoadSideChainTestData ¶
func LoadSideChainTestData(consensus *Consensus, derivationCache DerivationCacheInterface, reader io.Reader, patchedBlocks ...[]byte) (UniquePoolBlockSlice, error)
func (UniquePoolBlockSlice) Get ¶
func (s UniquePoolBlockSlice) Get(consensus *Consensus, id types.Hash) *PoolBlock
func (UniquePoolBlockSlice) GetHeight ¶
func (s UniquePoolBlockSlice) GetHeight(height uint64) (result UniquePoolBlockSlice)