chain

package
v4.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: ISC Imports: 29 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Callbacks

type Callbacks struct {
	Synced                       func(synced bool)
	FetchMissingCFiltersStarted  func()
	FetchMissingCFiltersProgress func(startCFiltersHeight, endCFiltersHeight int32)
	FetchMissingCFiltersFinished func()
	FetchHeadersStarted          func()
	FetchHeadersProgress         func(lastHeaderHeight int32, lastHeaderTime int64)
	FetchHeadersFinished         func()
	DiscoverAddressesStarted     func()
	DiscoverAddressesFinished    func()
	RescanStarted                func()
	RescanProgress               func(rescannedThrough int32)
	RescanFinished               func()
}

Callbacks contains optional callback functions to notify events during the syncing process. All callbacks are called synchronously and block the syncer from continuing.

type RPCOptions

type RPCOptions struct {
	Address     string
	DefaultPort string
	User        string
	Pass        string
	Dial        func(ctx context.Context, network, address string) (net.Conn, error)
	CA          []byte
	ClientCert  []byte
	ClientKey   []byte
	Insecure    bool
}

RPCOptions specifies the network and security settings for establishing a websocket connection to a dcrd JSON-RPC server.

type Syncer

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

Syncer implements wallet synchronization services by processing notifications from a dcrd JSON-RPC server.

func NewSyncer

func NewSyncer(w *wallet.Wallet, r *RPCOptions) *Syncer

NewSyncer creates a Syncer that will sync the wallet using dcrd JSON-RPC.

func (*Syncer) Blocks

func (s *Syncer) Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error)

Blocks is part of the wallet.NetworkBackend interface.

func (*Syncer) CFiltersV2

func (s *Syncer) CFiltersV2(ctx context.Context, blockHashes []*chainhash.Hash) ([]filterProof, error)

CFiltersV2 is part of the wallet.NetworkBackend interface.

func (*Syncer) Deployments

func (s *Syncer) Deployments(ctx context.Context) (map[string]dcrdtypes.AgendaInfo, error)

Deployments fulfills the DeploymentQuerier interface.

func (*Syncer) DisableDiscoverAccounts

func (s *Syncer) DisableDiscoverAccounts()

DisableDiscoverAccounts disables account discovery. This has an effect only if called before the main Run() executes the account discovery process.

func (*Syncer) ExistsLiveTickets

func (s *Syncer) ExistsLiveTickets(ctx context.Context, tickets []*chainhash.Hash) (bitset.Bytes, error)

ExistsLiveTickets fulfills the LiveTicketQuerier interface.

func (*Syncer) GetConfirmationHeight

func (s *Syncer) GetConfirmationHeight(ctx context.Context, txHash *chainhash.Hash) (int32, error)

GetConfirmationHeight fulfills the LiveTicketQuerier interface.

func (*Syncer) GetTxOut

func (s *Syncer) GetTxOut(ctx context.Context, txHash *chainhash.Hash, index uint32, tree int8, includeMempool bool) (*dcrdtypes.GetTxOutResult, error)

GetTxOut fulfills the LiveTicketQuerier interface.

func (*Syncer) LoadTxFilter

func (s *Syncer) LoadTxFilter(ctx context.Context, reload bool, addrs []stdaddr.Address, outpoints []wire.OutPoint) error

LoadTxFilter is part of the wallet.NetworkBackend interface.

func (*Syncer) PublishMixMessages

func (s *Syncer) PublishMixMessages(ctx context.Context, msgs ...mixing.Message) error

PublishMixMessages submits each mixing message to the dcrd mixpool for acceptance. If accepted, the messages are published to other peers.

func (*Syncer) PublishTransactions

func (s *Syncer) PublishTransactions(ctx context.Context, txs ...*wire.MsgTx) error

PublishTransactions is part of the wallet.NetworkBackend interface.

func (*Syncer) RPC

func (s *Syncer) RPC() *dcrd.RPC

RPC returns the JSON-RPC client to the underlying dcrd node.

func (*Syncer) Rescan

func (s *Syncer) Rescan(ctx context.Context, blocks []chainhash.Hash, save func(block *chainhash.Hash, txs []*wire.MsgTx) error) error

Rescan is part of the wallet.NetworkBackend interface.

func (*Syncer) Run

func (s *Syncer) Run(ctx context.Context) (err error)

Run synchronizes the wallet, returning when synchronization fails or the context is cancelled. If startupSync is true, all synchronization tasks needed to fully register the wallet for notifications and synchronize it with the dcrd server are performed. Otherwise, it will listen for notifications but not register for any updates.

func (*Syncer) SetCallbacks

func (s *Syncer) SetCallbacks(cb *Callbacks)

SetCallbacks sets the possible various callbacks that are used to notify interested parties to the syncing progress.

func (*Syncer) StakeDifficulty

func (s *Syncer) StakeDifficulty(ctx context.Context) (dcrutil.Amount, error)

StakeDifficulty is part of the wallet.NetworkBackend interface.

func (*Syncer) Synced

func (s *Syncer) Synced(ctx context.Context) (bool, int32)

Synced returns whether the syncer has completed syncing to the backend and the target height it is attempting to sync to.

func (*Syncer) UsedAddresses

func (s *Syncer) UsedAddresses(ctx context.Context, addrs []stdaddr.Address) (bitset.Bytes, error)

UsedAddresses fulfills the usedAddressesQuerier interface.

Jump to

Keyboard shortcuts

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