ticketbuyer

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2017 License: ISC Imports: 15 Imported by: 0

README

ticketbuyer

Package ticketbuyer provides automatic purchase of tickets from a Decred wallet.

Documentation

GoDoc

Full go doc style documentation for the project can be viewed online without installing this package by using the GoDoc site here: http://godoc.org/github.com/decred/dcrwallet/ticketbuyer

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/decred/dcrwallet/ticketbuyer

Installation

$ go get github.com/decred/dcrwallet/ticketbuyer

Package ticketbuyer is licensed under the copyfree ISC License.

Documentation

Overview

Package ticketbuyer provides an implementation of automatic ticket purchasing for a decred wallet.

Index

Constants

View Source
const (
	// TicketFeeMean is the string indicating that the mean ticket fee
	// should be used when determining ticket fee.
	TicketFeeMean = "mean"

	// TicketFeeMedian is the string indicating that the median ticket fee
	// should be used when determining ticket fee.
	TicketFeeMedian = "median"

	// PriceTargetVWAP is the string indicating that the volume
	// weighted average price should be used as the price target.
	PriceTargetVWAP = "vwap"

	// PriceTargetPool is the string indicating that the ticket pool
	// price should be used as the price target.
	PriceTargetPool = "pool"

	// PriceTargetDual is the string indicating that a combination of the
	// ticket pool price and the ticket VWAP should be used as the
	// price target.
	PriceTargetDual = "dual"
)
View Source
const (
	// AvgPriceVWAPMode indicates to use only the VWAP.
	AvgPriceVWAPMode = iota

	// AvgPricePoolMode indicates to use only the average
	// price in the ticket pool.
	AvgPricePoolMode

	// AvgPriceDualMode indicates to use bothe the VWAP and
	// the average pool price.
	AvgPriceDualMode
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger btclog.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 btclog.

Types

type Config

type Config struct {
	AccountName               string
	AvgPriceMode              string
	AvgPriceVWAPDelta         int
	BalanceToMaintainAbsolute int64
	BalanceToMaintainRelative float64
	BlocksToAvg               int
	DontWaitForTickets        bool
	ExpiryDelta               int
	FeeSource                 string
	FeeTargetScaling          float64
	MinFee                    int64
	MaxFee                    int64
	MaxPerBlock               int
	MaxPriceAbsolute          int64
	MaxPriceRelative          float64
	MaxInMempool              int
	PoolAddress               string
	PoolFees                  float64
	NoSpreadTicketPurchases   bool
	TicketAddress             string
	TxFee                     int64
}

Config stores the configuration options for ticket buyer.

type PurchaseManager

type PurchaseManager struct {
	// contains filtered or unexported fields
}

PurchaseManager is the main handler of websocket notifications to pass to the purchaser and internal quit notifications.

func NewPurchaseManager

func NewPurchaseManager(w *wallet.Wallet, purchaser *TicketPurchaser,
	ntfnChan <-chan *wallet.MainTipChangedNotification, passphrase []byte) *PurchaseManager

NewPurchaseManager creates a new PurchaseManager.

func (*PurchaseManager) NotificationHandler

func (p *PurchaseManager) NotificationHandler()

NotificationHandler handles notifications, which trigger ticket purchases.

func (*PurchaseManager) Purchaser added in v1.0.0

func (p *PurchaseManager) Purchaser() *TicketPurchaser

Purchaser returns the ticket buyer instance associated with the purchase manager.

func (*PurchaseManager) Start added in v0.8.0

func (p *PurchaseManager) Start()

Start starts the purchase manager goroutines.

func (*PurchaseManager) Stop added in v0.8.0

func (p *PurchaseManager) Stop()

Stop signals all purchase manager goroutines to shutdown.

func (*PurchaseManager) WaitForShutdown added in v0.8.0

func (p *PurchaseManager) WaitForShutdown()

WaitForShutdown blocks until all purchase manager goroutines have finished executing.

type PurchaseStats

type PurchaseStats struct {
	Height        int64
	PriceMaxScale float64
	PriceAverage  dcrutil.Amount
	PriceNext     dcrutil.Amount
	PriceCurrent  dcrutil.Amount
	Purchased     int
	LeftWindow    int
	Balance       dcrutil.Amount
	TicketPrice   dcrutil.Amount
}

PurchaseStats stats is a collection of statistics related to the ticket purchase.

type TicketPurchaser

type TicketPurchaser struct {
	// contains filtered or unexported fields
}

TicketPurchaser is the main handler for purchasing tickets. It decides whether or not to do so based on information obtained from daemon and wallet chain servers.

func NewTicketPurchaser

func NewTicketPurchaser(cfg *Config,
	dcrdChainSvr *dcrrpcclient.Client,
	w *wallet.Wallet,
	activeNet *chaincfg.Params) (*TicketPurchaser, error)

NewTicketPurchaser creates a new TicketPurchaser.

func (*TicketPurchaser) Account added in v1.0.0

func (t *TicketPurchaser) Account() uint32

Account returns the account to use for purchasing tickets.

func (*TicketPurchaser) AccountName added in v1.0.0

func (t *TicketPurchaser) AccountName() (string, error)

AccountName returns the account name to use for purchasing tickets.

func (*TicketPurchaser) BalanceToMaintain added in v1.0.0

func (t *TicketPurchaser) BalanceToMaintain() dcrutil.Amount

BalanceToMaintain returns the balance to be maintained in the wallet.

func (*TicketPurchaser) Config added in v1.0.0

func (t *TicketPurchaser) Config() (*Config, error)

Config returns the current ticket buyer configuration.

func (*TicketPurchaser) ExpiryDelta added in v1.0.0

func (t *TicketPurchaser) ExpiryDelta() int

ExpiryDelta returns the expiry delta.

func (*TicketPurchaser) MaxFee added in v1.0.0

func (t *TicketPurchaser) MaxFee() dcrutil.Amount

MaxFee returns the max ticket fee per KB to use when purchasing tickets.

func (*TicketPurchaser) MaxInMempool added in v1.0.0

func (t *TicketPurchaser) MaxInMempool() int

MaxInMempool returns the max tickets to allow in the mempool.

func (*TicketPurchaser) MaxPerBlock added in v1.0.0

func (t *TicketPurchaser) MaxPerBlock() int

MaxPerBlock returns the max tickets to purchase for a block.

func (*TicketPurchaser) MaxPriceAbsolute added in v1.0.0

func (t *TicketPurchaser) MaxPriceAbsolute() dcrutil.Amount

MaxPriceAbsolute returns the max absolute price to purchase a ticket.

func (*TicketPurchaser) MaxPriceRelative added in v1.0.0

func (t *TicketPurchaser) MaxPriceRelative() float64

MaxPriceRelative returns the scaling factor which is multipled by average price to calculate a relative max for the ticket price.

func (*TicketPurchaser) MinFee added in v1.0.0

func (t *TicketPurchaser) MinFee() dcrutil.Amount

MinFee returns the min ticket fee per KB to use when purchasing tickets.

func (*TicketPurchaser) PoolAddress added in v1.0.0

func (t *TicketPurchaser) PoolAddress() dcrutil.Address

PoolAddress returns the pool address where ticket fees are sent.

func (*TicketPurchaser) PoolFees added in v1.0.0

func (t *TicketPurchaser) PoolFees() float64

PoolFees returns the percent of ticket per ticket fee mandated by the pool.

func (*TicketPurchaser) Purchase

func (t *TicketPurchaser) Purchase(height int64) (*PurchaseStats, error)

Purchase is the main handler for purchasing tickets for the user. TODO Not make this an inlined pile of crap.

func (*TicketPurchaser) SetAccount added in v1.0.0

func (t *TicketPurchaser) SetAccount(account uint32)

SetAccount sets the account to use for purchasing tickets.

func (*TicketPurchaser) SetBalanceToMaintain added in v1.0.0

func (t *TicketPurchaser) SetBalanceToMaintain(balanceToMaintain int64)

SetBalanceToMaintain sets the balance to be maintained in the wallet.

func (*TicketPurchaser) SetExpiryDelta added in v1.0.0

func (t *TicketPurchaser) SetExpiryDelta(expiryDelta int)

SetExpiryDelta sets the expiry delta.

func (*TicketPurchaser) SetMaxFee added in v1.0.0

func (t *TicketPurchaser) SetMaxFee(maxFee int64)

SetMaxFee sets the max ticket fee per KB to use when purchasing tickets.

func (*TicketPurchaser) SetMaxInMempool added in v1.0.0

func (t *TicketPurchaser) SetMaxInMempool(maxInMempool int)

SetMaxInMempool sets the max tickets to allow in the mempool.

func (*TicketPurchaser) SetMaxPerBlock added in v1.0.0

func (t *TicketPurchaser) SetMaxPerBlock(maxPerBlock int)

SetMaxPerBlock sets the max tickets to purchase for a block.

func (*TicketPurchaser) SetMaxPriceAbsolute added in v1.0.0

func (t *TicketPurchaser) SetMaxPriceAbsolute(maxPriceAbsolute int64)

SetMaxPriceAbsolute sets the max absolute price to purchase a ticket.

func (*TicketPurchaser) SetMaxPriceRelative added in v1.0.0

func (t *TicketPurchaser) SetMaxPriceRelative(maxPriceRelative float64)

SetMaxPriceRelative sets scaling factor.

func (*TicketPurchaser) SetMinFee added in v1.0.0

func (t *TicketPurchaser) SetMinFee(minFee int64)

SetMinFee sets the min ticket fee per KB to use when purchasing tickets.

func (*TicketPurchaser) SetPoolAddress added in v1.0.0

func (t *TicketPurchaser) SetPoolAddress(poolAddress dcrutil.Address)

SetPoolAddress sets the pool address where ticket fees are sent.

func (*TicketPurchaser) SetPoolFees added in v1.0.0

func (t *TicketPurchaser) SetPoolFees(poolFees float64)

SetPoolFees sets the percent of ticket per ticket fee mandated by the pool.

func (*TicketPurchaser) SetTicketAddress added in v1.0.0

func (t *TicketPurchaser) SetTicketAddress(ticketAddress dcrutil.Address)

SetTicketAddress sets the address to send ticket outputs to.

func (*TicketPurchaser) TicketAddress added in v1.0.0

func (t *TicketPurchaser) TicketAddress() dcrutil.Address

TicketAddress returns the address to send ticket outputs to.

Jump to

Keyboard shortcuts

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