Documentation ¶
Index ¶
- Constants
- Variables
- func AccountID(address string) *string
- func CalculatePPLNSSharePercentages(db *bolt.DB, poolFee float64, height uint32, periodSecs uint32) (map[string]*big.Rat, error)
- func CalculatePPSSharePercentages(db *bolt.DB, poolFee float64, height uint32) (map[string]*big.Rat, error)
- func CalculatePoolDifficulty(net *chaincfg.Params, hashRate *big.Int, targetTimeSecs *big.Int) (*big.Int, error)
- func CalculatePoolTarget(net *chaincfg.Params, hashRate *big.Int, targetTimeSecs *big.Int) (*big.Int, *big.Int, error)
- func CalculateSharePercentages(shares []*Share) (map[string]*big.Rat, error)
- func DifficultyToTarget(net *chaincfg.Params, difficulty *big.Int) (*big.Int, error)
- func DisableLog()
- func ErrDivideByZero() error
- func ErrNotSupported(tp, action string) error
- func GeneratePaymentDetails(db *bolt.DB, poolFeeAddrs []bitumutil.Address, eligiblePmts []*PaymentBundle, ...) (map[string]bitumutil.Amount, *bitumutil.Amount, error)
- func GeneratePaymentID(createdOnNano int64, height uint32, account string) []byte
- func PayPerLastNShares(db *bolt.DB, amount bitumutil.Amount, poolFee float64, height uint32, ...) error
- func PayPerShare(db *bolt.DB, total bitumutil.Amount, poolFee float64, height uint32, ...) error
- func PruneShares(db *bolt.DB, minNano int64) error
- func UseLogger(logger slog.Logger)
- type Account
- type Payment
- func CalculatePayments(percentages map[string]*big.Rat, total bitumutil.Amount, poolFee float64, ...) ([]*Payment, error)
- func FetchArchivedPaymentsForAccount(db *bolt.DB, account string, n uint) ([]*Payment, error)
- func FetchMaturePendingPayments(db *bolt.DB, height uint32) ([]*Payment, error)
- func FetchPendingPayments(db *bolt.DB) ([]*Payment, error)
- func FetchPendingPaymentsAtHeight(db *bolt.DB, height uint32) ([]*Payment, error)
- func FilterPayments(db *bolt.DB, filter func(payment *Payment) bool) ([]*Payment, error)
- func GetPayment(db *bolt.DB, id []byte) (*Payment, error)
- func NewPayment(account string, amount bitumutil.Amount, height uint32, estMaturity uint32) *Payment
- type PaymentBundle
- type Share
Constants ¶
const ( CPU = "cpu" InnosiliconD9 = "innosilicond9" // ObeliskBITUM1 = "obeliskbitum1" AntminerDR3 = "antminerdr3" AntminerDR5 = "antminerdr5" WhatsminerD1 = "whatsminerd1" )
Miner types lists all known BITUM miners
Variables ¶
var ( // PoolFeesK is the key used to track pool fee payouts. PoolFeesK = "fees" // PPS represents the pay per share payment method. PPS = "pps" // PPLNS represents the pay per last n shares payment method. PPLNS = "pplns" )
var MinerHashes = map[string]*big.Int{ CPU: new(big.Int).SetInt64(70E3), InnosiliconD9: new(big.Int).SetInt64(2.4E12), AntminerDR3: new(big.Int).SetInt64(7.8E12), AntminerDR5: new(big.Int).SetInt64(35E12), WhatsminerD1: new(big.Int).SetInt64(48E12), }
MinerHashes is a map of all known BITUM miners and their coressponding hashrates.
var MinerPorts = map[string]uint32{ CPU: 5550, InnosiliconD9: 5552, AntminerDR3: 5553, AntminerDR5: 5554, WhatsminerD1: 5555, }
MinerPorts is a map of all known BITUM miners and the coressponding ports configured to be connected on.
CPU: new(big.Rat).SetFloat64(1.0), InnosiliconD9: new(big.Rat).SetFloat64(2.182), AntminerDR3: new(big.Rat).SetFloat64(7.091), AntminerDR5: new(big.Rat).SetFloat64(31.181), WhatsminerD1: new(big.Rat).SetFloat64(43.636), }
ShareWeights reprsents the associated weights for each known BITUM miner. With the share weight of the lowest hash BITUM miner (LHM) being 1, the rest were calculated as :
(Hash of Miner X * Weight of LHM)/ Hash of LHM
Functions ¶
func CalculatePPLNSSharePercentages ¶
func CalculatePPLNSSharePercentages(db *bolt.DB, poolFee float64, height uint32, periodSecs uint32) (map[string]*big.Rat, error)
CalculatePPLNSSharePercentages computes the current dividend percentages due pool accounts based on work performed measured by the PPLNS payment scheme.
func CalculatePPSSharePercentages ¶
func CalculatePPSSharePercentages(db *bolt.DB, poolFee float64, height uint32) (map[string]*big.Rat, error)
CalculatePPLNSSharePercentages computes the current dividend percentages due pool accounts based on work performed measured by the PPS payment scheme.
func CalculatePoolDifficulty ¶
func CalculatePoolDifficulty(net *chaincfg.Params, hashRate *big.Int, targetTimeSecs *big.Int) (*big.Int, error)
CalculatePoolDifficulty determines the difficulty at which the provided hashrate can generate a pool share by the provided target time.
func CalculatePoolTarget ¶
func CalculatePoolTarget(net *chaincfg.Params, hashRate *big.Int, targetTimeSecs *big.Int) (*big.Int, *big.Int, error)
CalculatePoolTarget determines the target difficulty at which the provided hashrate can generate a pool share by the provided target time.
func CalculateSharePercentages ¶
CalculateSharePercentages calculates the percentages due each account according to their weighted shares.
func DifficultyToTarget ¶
DifficultyToTarget converts the provided difficulty to a target based on the active network.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func ErrDivideByZero ¶
func ErrDivideByZero() error
ErrDivideByZero is returned the divisor of division operation is zero.
func ErrNotSupported ¶
ErrNotSupported is returned when an entity does not support an action.
func GeneratePaymentDetails ¶
func GeneratePaymentDetails(db *bolt.DB, poolFeeAddrs []bitumutil.Address, eligiblePmts []*PaymentBundle, maxTxFeeReserve bitumutil.Amount, txFeeReserve *bitumutil.Amount) (map[string]bitumutil.Amount, *bitumutil.Amount, error)
GeneratePaymentDetails generates kv pair of addresses and payment amounts from the provided eligible payments.
func GeneratePaymentID ¶
GeneratePaymentID generates a unique id using the provided account and the created on nano time.
func PayPerLastNShares ¶
func PayPerLastNShares(db *bolt.DB, amount bitumutil.Amount, poolFee float64, height uint32, coinbaseMaturity uint16, periodSecs uint32) error
PayPerLastNShares generates a payment bundle comprised of payments to all participating accounts within the last n time period provided.
func PayPerShare ¶
func PayPerShare(db *bolt.DB, total bitumutil.Amount, poolFee float64, height uint32, coinbaseMaturity uint16) error
PayPerShare generates a payment bundle comprised of payments to all participating accounts. Payments are calculated based on work contributed to the pool since the last payment batch.
func PruneShares ¶
PruneShares removes invalidated shares from the db.
Types ¶
type Account ¶
type Account struct { UUID string `json:"uuid"` Address string `json:"address"` CreatedOn uint64 `json:"createdon"` }
Account represents an anonymous mining pool account.
func FetchAccount ¶
FetchAccount fetches the account referenced by the provided id.
func NewAccount ¶
NewAccount generates a new account.
type Payment ¶
type Payment struct { Account string `json:"account"` EstimatedMaturity uint32 `json:"estimatedmaturity"` Height uint32 `json:"height"` Amount bitumutil.Amount `json:"amount"` CreatedOn int64 `json:"createdon"` PaidOnHeight uint32 `json:"paidonheight"` }
Payment represents an outstanding payment for a pool account.
func CalculatePayments ¶
func CalculatePayments(percentages map[string]*big.Rat, total bitumutil.Amount, poolFee float64, height uint32, estMaturity uint32) ([]*Payment, error)
CalculatePayments calculates the payments due participating accounts.
func FetchArchivedPaymentsForAccount ¶
FetchArchivedPaymentsForAccount fetches the N most recent archived payments for the provided account. List is ordered, most recent comes first.
func FetchMaturePendingPayments ¶
FetchMaturePendingPayments fetches all payments past their estimated maturities which have not been paid yet.
func FetchPendingPayments ¶
FetchPendingPayments fetches all unpaid payments.
func FetchPendingPaymentsAtHeight ¶
FetchPendingPaymentsAtHeight fetches all pending payments at the provided height.
func FilterPayments ¶
FilterPayments iterates the payments bucket, the result set is generated based on the provided filter.
func GetPayment ¶
GetPayment fetches the payment referenced by the provided id.
func NewPayment ¶
func NewPayment(account string, amount bitumutil.Amount, height uint32, estMaturity uint32) *Payment
NewPayment creates a payment instance.
type PaymentBundle ¶
PaymentBundle is a convenience type for grouping payments for an account.
func FetchEligiblePaymentBundles ¶
func FetchEligiblePaymentBundles(db *bolt.DB, height uint32, minPayment bitumutil.Amount) ([]*PaymentBundle, error)
FetchEligiblePaymentBundles fetches payment bundles greater than the configured minimum payment.
func GeneratePaymentBundles ¶
func GeneratePaymentBundles(payments []*Payment) []*PaymentBundle
GeneratePaymentBundles creates account payment bundles from the provided set of payments.
func NewPaymentBundle ¶
func NewPaymentBundle(account string) *PaymentBundle
NewPaymentBundle initializes a payment bundle instance.
func (*PaymentBundle) ArchivePayments ¶
func (bundle *PaymentBundle) ArchivePayments(db *bolt.DB) error
ArchivePayments removes all payments included in the payment bundle from the payment bucket and archives them.
func (*PaymentBundle) Total ¶
func (bundle *PaymentBundle) Total() bitumutil.Amount
Total returns the sum of all payments amount for the account.
func (*PaymentBundle) UpdateAsPaid ¶
func (bundle *PaymentBundle) UpdateAsPaid(db *bolt.DB, height uint32)
UpdateAsPaid updates all associated payments referenced by a payment bundle as paid.
type Share ¶
type Share struct {}
Share represents verifiable work performed by a pool client.
func PPLNSEligibleShares ¶
PPLNSEligibleShares fetches all shares keyed greater than the provided minimum.
func PPSEligibleShares ¶
PPSEligibleShares fetches all shares within the provided inclusive bounds.