dividend

package
v0.0.0-...-b221635 Latest Latest
Warning

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

Go to latest
Published: May 25, 2019 License: ISC Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CPU           = "cpu"
	InnosiliconD9 = "innosilicond9"
	// ObeliskBITUM1   = "obeliskbitum1"
	AntminerDR3  = "antminerdr3"
	AntminerDR5  = "antminerdr5"
	WhatsminerD1 = "whatsminerd1"
)

Miner types lists all known BITUM miners

Variables

View Source
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"
)
View Source
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.

View Source
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.

View Source
var ShareWeights = map[string]*big.Rat{
	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 AccountID

func AccountID(address string) *string

AccountID geenrates an id using provided address of the account.

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

func CalculateSharePercentages(shares []*Share) (map[string]*big.Rat, error)

CalculateSharePercentages calculates the percentages due each account according to their weighted shares.

func DifficultyToTarget

func DifficultyToTarget(net *chaincfg.Params, difficulty *big.Int) (*big.Int, error)

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

func ErrNotSupported(tp, action string) error

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

func GeneratePaymentID(createdOnNano int64, height uint32, account string) []byte

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

func PruneShares(db *bolt.DB, minNano int64) error

PruneShares removes invalidated shares from the db.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

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

func FetchAccount(db *bolt.DB, id []byte) (*Account, error)

FetchAccount fetches the account referenced by the provided id.

func NewAccount

func NewAccount(address string) (*Account, error)

NewAccount generates a new account.

func (*Account) Create

func (acc *Account) Create(db *bolt.DB) error

Create persists the account to the database.

func (*Account) Delete

func (acc *Account) Delete(db *bolt.DB) error

Delete purges the referenced account from the database.

func (*Account) Update

func (acc *Account) Update(db *bolt.DB) error

Update is not supported for accounts.

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

func FetchArchivedPaymentsForAccount(db *bolt.DB, account string, n uint) ([]*Payment, error)

FetchArchivedPaymentsForAccount fetches the N most recent archived payments for the provided account. List is ordered, most recent comes first.

func FetchMaturePendingPayments

func FetchMaturePendingPayments(db *bolt.DB, height uint32) ([]*Payment, error)

FetchMaturePendingPayments fetches all payments past their estimated maturities which have not been paid yet.

func FetchPendingPayments

func FetchPendingPayments(db *bolt.DB) ([]*Payment, error)

FetchPendingPayments fetches all unpaid payments.

func FetchPendingPaymentsAtHeight

func FetchPendingPaymentsAtHeight(db *bolt.DB, height uint32) ([]*Payment, error)

FetchPendingPaymentsAtHeight fetches all pending payments at the provided height.

func FilterPayments

func FilterPayments(db *bolt.DB, filter func(payment *Payment) bool) ([]*Payment, error)

FilterPayments iterates the payments bucket, the result set is generated based on the provided filter.

func GetPayment

func GetPayment(db *bolt.DB, id []byte) (*Payment, error)

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.

func (*Payment) Create

func (payment *Payment) Create(db *bolt.DB) error

Create persists a payment to the database.

func (*Payment) Delete

func (payment *Payment) Delete(db *bolt.DB) error

Delete purges the referenced pending payment from the database.

func (*Payment) Update

func (payment *Payment) Update(db *bolt.DB) error

Update persists the updated payment to the database.

type PaymentBundle

type PaymentBundle struct {
	Account  string
	Payments []*Payment
}

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 {
	Account   string   `json:"account"`
	Weight    *big.Rat `json:"weight"`
	CreatedOn int64    `json:"createdOn"`
}

Share represents verifiable work performed by a pool client.

func NewShare

func NewShare(account string, weight *big.Rat) *Share

NewShare creates a shate with the provided account and weight.

func PPLNSEligibleShares

func PPLNSEligibleShares(db *bolt.DB, min []byte) ([]*Share, error)

PPLNSEligibleShares fetches all shares keyed greater than the provided minimum.

func PPSEligibleShares

func PPSEligibleShares(db *bolt.DB, min []byte, max []byte) ([]*Share, error)

PPSEligibleShares fetches all shares within the provided inclusive bounds.

func (*Share) Create

func (s *Share) Create(db *bolt.DB) error

Create persists a share to the database.

func (*Share) Delete

func (s *Share) Delete(db *bolt.DB) error

Delete is not supported for shares.

func (*Share) Update

func (s *Share) Update(db *bolt.DB) error

Update is not supported for shares.

Jump to

Keyboard shortcuts

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