ticketbuyer

package
v0.0.0-...-e703aee Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: ISC Imports: 15 Imported by: 0

README

ticketbuyer

Package ticketbuyer provides automatic purchase of tickets from a Fonero 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/fonero-project/fnowallet/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/fonero-project/fnowallet/ticketbuyer

Installation

$ go get github.com/fonero-project/fnowallet/ticketbuyer

Package ticketbuyer is licensed under the copyfree ISC License.

Documentation

Overview

Package ticketbuyer provides an implementation of automatic ticket purchasing for a fonero 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 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 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               fnoutil.Address
	PoolFees                  float64
	NoSpreadTicketPurchases   bool
	VotingAddress             fnoutil.Address
	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

func (p *PurchaseManager) Purchaser() *TicketPurchaser

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

func (*PurchaseManager) Start

func (p *PurchaseManager) Start()

Start starts the purchase manager goroutines.

func (*PurchaseManager) Stop

func (p *PurchaseManager) Stop()

Stop signals all purchase manager goroutines to shutdown.

func (*PurchaseManager) WaitForShutdown

func (p *PurchaseManager) WaitForShutdown()

WaitForShutdown blocks until all purchase manager goroutines have finished executing.

type PurchaseStats

type PurchaseStats struct {
	Height        int64
	PriceMaxScale float64
	PriceAverage  fnoutil.Amount
	PriceNext     fnoutil.Amount
	PriceCurrent  fnoutil.Amount
	Purchased     int
	LeftWindow    int
	Balance       fnoutil.Amount
	TicketPrice   fnoutil.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,
	fnodChainSvr *fnorpcclient.Client,
	w *wallet.Wallet,
	activeNet *chaincfg.Params) (*TicketPurchaser, error)

NewTicketPurchaser creates a new TicketPurchaser.

func (*TicketPurchaser) Account

func (t *TicketPurchaser) Account() uint32

Account returns the account to use for purchasing tickets.

func (*TicketPurchaser) AccountName

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

AccountName returns the account name to use for purchasing tickets.

func (*TicketPurchaser) BalanceToMaintain

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

BalanceToMaintain returns the balance to be maintained in the wallet.

func (*TicketPurchaser) Config

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

Config returns the current ticket buyer configuration.

func (*TicketPurchaser) ExpiryDelta

func (t *TicketPurchaser) ExpiryDelta() int

ExpiryDelta returns the expiry delta.

func (*TicketPurchaser) MaxFee

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

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

func (*TicketPurchaser) MaxInMempool

func (t *TicketPurchaser) MaxInMempool() int

MaxInMempool returns the max tickets to allow in the mempool.

func (*TicketPurchaser) MaxPerBlock

func (t *TicketPurchaser) MaxPerBlock() int

MaxPerBlock returns the max tickets to purchase for a block.

func (*TicketPurchaser) MaxPriceAbsolute

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

MaxPriceAbsolute returns the max absolute price to purchase a ticket.

func (*TicketPurchaser) MaxPriceRelative

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

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

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

func (*TicketPurchaser) PoolAddress

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

PoolAddress returns the pool address where ticket fees are sent.

func (*TicketPurchaser) PoolFees

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

func (t *TicketPurchaser) SetAccount(account uint32)

SetAccount sets the account to use for purchasing tickets.

func (*TicketPurchaser) SetBalanceToMaintain

func (t *TicketPurchaser) SetBalanceToMaintain(balanceToMaintain int64)

SetBalanceToMaintain sets the balance to be maintained in the wallet.

func (*TicketPurchaser) SetExpiryDelta

func (t *TicketPurchaser) SetExpiryDelta(expiryDelta int)

SetExpiryDelta sets the expiry delta.

func (*TicketPurchaser) SetMaxFee

func (t *TicketPurchaser) SetMaxFee(maxFee int64)

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

func (*TicketPurchaser) SetMaxInMempool

func (t *TicketPurchaser) SetMaxInMempool(maxInMempool int)

SetMaxInMempool sets the max tickets to allow in the mempool.

func (*TicketPurchaser) SetMaxPerBlock

func (t *TicketPurchaser) SetMaxPerBlock(maxPerBlock int)

SetMaxPerBlock sets the max tickets to purchase for a block.

func (*TicketPurchaser) SetMaxPriceAbsolute

func (t *TicketPurchaser) SetMaxPriceAbsolute(maxPriceAbsolute int64)

SetMaxPriceAbsolute sets the max absolute price to purchase a ticket.

func (*TicketPurchaser) SetMaxPriceRelative

func (t *TicketPurchaser) SetMaxPriceRelative(maxPriceRelative float64)

SetMaxPriceRelative sets scaling factor.

func (*TicketPurchaser) SetMinFee

func (t *TicketPurchaser) SetMinFee(minFee int64)

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

func (*TicketPurchaser) SetPoolAddress

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

SetPoolAddress sets the pool address where ticket fees are sent.

func (*TicketPurchaser) SetPoolFees

func (t *TicketPurchaser) SetPoolFees(poolFees float64)

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

func (*TicketPurchaser) SetVotingAddress

func (t *TicketPurchaser) SetVotingAddress(votingAddress fnoutil.Address)

SetVotingAddress sets the address to send ticket outputs to.

func (*TicketPurchaser) VotingAddress

func (t *TicketPurchaser) VotingAddress() fnoutil.Address

VotingAddress returns the address to send ticket outputs to.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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