stakepool

package
v0.0.0-...-bc1fc02 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: ISC, MIT Imports: 18 Imported by: 0

Documentation

Overview

Package stakepool holds the Stakepool struct and processes incomming commands and notifications.

Index

Constants

This section is empty.

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 MsgTxFromHex

func MsgTxFromHex(txhex string) (*wire.MsgTx, error)

MsgTxFromHex returns a wire.MsgTx struct built from the transaction hex string

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 Client

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

Client holds the information related to an rpcclient and handles access to that client through a mutex.

It should be noted that this is a temporary fix to the problem that rpcclient does not return an error when autoreconnect is turned on but the client is disconnected. The permanent solution is to change the behaviour of rpccleint. TODO: Remove this file.

func NewClient

func NewClient(ctx context.Context, wg *sync.WaitGroup, cfg *rpcclient.ConnConfig, ntfnHandlers *rpcclient.NotificationHandlers) (*Client, error)

NewClient creates a new Client and starts the automatic reconnection handler. Returns an error if unable to construct a new rpcclient.

func (*Client) Connected

func (c *Client) Connected() <-chan struct{}

Connected returns a receiving copy of the current connected channel. If disconnected and the channel is not yet blocking, creates a new channel that will be closed on a successful reconnect.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected checks and returns whethere the client is currently connected.

func (*Client) RPCClient

func (c *Client) RPCClient() *rpcclient.Client

RPCClient allows access to the underlying rpcclient by providing a copy of its address.

type NewTicketsForBlock

type NewTicketsForBlock struct {
	BlockHash   *chainhash.Hash
	BlockHeight int64
	NewTickets  []*chainhash.Hash
}

type SpentMissedTicketsForBlock

type SpentMissedTicketsForBlock struct {
	BlockHash   *chainhash.Hash
	BlockHeight int64
	SmTickets   map[*chainhash.Hash]bool
}

type Stakepoold

type Stakepoold struct {
	sync.RWMutex

	// locking required
	AddedLowFeeTicketsMSA   map[chainhash.Hash]string            // [ticket]multisigaddr
	IgnoredLowFeeTicketsMSA map[chainhash.Hash]string            // [ticket]multisigaddr
	LiveTicketsMSA          map[chainhash.Hash]string            // [ticket]multisigaddr
	UserVotingConfig        map[string]userdata.UserVotingConfig // [multisigaddr]

	// no locking required
	DataPath               string
	ColdWalletExtPub       string
	FeeAddrs               map[string]struct{}
	PoolFees               float64
	NewTicketsChan         chan NewTicketsForBlock
	NodeConnection         *rpcclient.Client
	Params                 *chaincfg.Params
	SpentmissedTicketsChan chan SpentMissedTicketsForBlock
	UserData               *userdata.UserData
	VotingConfig           *VotingConfig
	WalletConnection       *Client
	WinningTicketsChan     chan WinningTicketsForBlock
	Testing                bool // enabled only for testing
}

func (*Stakepoold) AccountSyncAddressIndex

func (spd *Stakepoold) AccountSyncAddressIndex(account string, branch uint32, index int) error

func (*Stakepoold) AddMissingTicket

func (spd *Stakepoold) AddMissingTicket(ticketHash []byte) error

func (*Stakepoold) CreateMultisig

func (spd *Stakepoold) CreateMultisig(addresses []string) (*wallettypes.CreateMultiSigResult, error)

CreateMultisig decodes the provided array of addresses, and then passes them to eacrwallet to create a 1-of-N multisig address.

func (*Stakepoold) EvaluateStakePoolTicket

func (spd *Stakepoold) EvaluateStakePoolTicket(tx *wire.MsgTx, blockHeight int32) (bool, error)

EvaluateStakePoolTicket evaluates a voting service ticket to see if it's acceptable to the voting service. The ticket must pay out to the voting service cold wallet, and must have a sufficient fee.

func (*Stakepoold) GetStakeInfo

func (spd *Stakepoold) GetStakeInfo() (*wallettypes.GetStakeInfoResult, error)

GetStakeInfo performs the rpc command GetStakeInfo.

func (*Stakepoold) GetTickets

func (spd *Stakepoold) GetTickets(includeImmature bool) ([]*chainhash.Hash, error)

func (*Stakepoold) ImportMissingScripts

func (spd *Stakepoold) ImportMissingScripts(scripts [][]byte, rescanHeight int) error

ImportMissingScripts accepts a list of redeem scripts and a rescan height. It will import all but one of the scripts without triggering a wallet rescan, and finally trigger a rescan from the provided height after importing the last one.

func (*Stakepoold) ImportNewScript

func (spd *Stakepoold) ImportNewScript(script []byte) (int64, error)

ImportNewScript will import a redeem script into eacrwallet. No rescan is performed because we are importing a brand new script, it shouldn't have any associated history. Current block height is returned to indicate which height the new user has registered.

func (*Stakepoold) ListScripts

func (spd *Stakepoold) ListScripts() ([][]byte, error)

func (*Stakepoold) NewTicketHandler

func (spd *Stakepoold) NewTicketHandler(ctx context.Context, wg *sync.WaitGroup)

func (*Stakepoold) ProcessWinningTickets

func (spd *Stakepoold) ProcessWinningTickets(wt WinningTicketsForBlock)

ProcessWinningTickets is called every time a new block comes in to handle voting. The function requires ASAP processing for each vote and therefore it is not sequential and hard to read. This is unfortunate but a reality of speeding up code.

func (*Stakepoold) SpentmissedTicketHandler

func (spd *Stakepoold) SpentmissedTicketHandler(ctx context.Context, wg *sync.WaitGroup)

func (*Stakepoold) StakePoolUserInfo

func (spd *Stakepoold) StakePoolUserInfo(multisigAddress string) (*wallettypes.StakePoolUserInfoResult, error)

func (*Stakepoold) UpdateTicketData

func (spd *Stakepoold) UpdateTicketData(newAddedLowFeeTicketsMSA map[chainhash.Hash]string)

func (*Stakepoold) UpdateTicketDataFromMySQL

func (spd *Stakepoold) UpdateTicketDataFromMySQL() error

func (*Stakepoold) UpdateUserData

func (spd *Stakepoold) UpdateUserData(newUserVotingConfig map[string]userdata.UserVotingConfig)

func (*Stakepoold) UpdateUserDataFromMySQL

func (spd *Stakepoold) UpdateUserDataFromMySQL() error

func (*Stakepoold) ValidateAddress

func (spd *Stakepoold) ValidateAddress(address string) (*wallettypes.ValidateAddressWalletResult, error)

func (*Stakepoold) WalletInfo

func (spd *Stakepoold) WalletInfo() (*wallettypes.WalletInfoResult, error)

func (*Stakepoold) WinningTicketHandler

func (spd *Stakepoold) WinningTicketHandler(ctx context.Context, wg *sync.WaitGroup)

type VotingConfig

type VotingConfig struct {
	VoteBits         uint16
	VoteVersion      uint32
	VoteBitsExtended string
}

VotingConfig contains global voting defaults.

type WinningTicketsForBlock

type WinningTicketsForBlock struct {
	BlockHash      *chainhash.Hash
	BlockHeight    int64
	WinningTickets []*chainhash.Hash
}

Jump to

Keyboard shortcuts

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