spv

package
v0.0.0-...-9e8562e Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: ISC Imports: 22 Imported by: 0

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.

Types

type Notifications

type Notifications struct {
	Synced                       func(sync bool)
	PeerConnected                func(peerCount int32, addr string)
	PeerDisconnected             func(peerCount int32, addr string)
	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()

	// MempoolTxs is called whenever new relevant unmined transactions are
	// observed and saved.
	MempoolTxs func(txs []*wire.MsgTx)

	// TipChanged is called when the main chain tip block changes.
	// When reorgDepth is zero, the new block is a direct child of the previous tip.
	// If non-zero, one or more blocks described by the parameter were removed from
	// the previous main chain.
	// txs contains all relevant transactions mined in each attached block in
	// unspecified order.
	// reorgDepth is guaranteed to be non-negative.
	TipChanged func(tip *wire.BlockHeader, reorgDepth int32, txs []*wire.MsgTx)
}

Notifications struct to contain all of the upcoming callbacks that will be used to update the rpc streams for syncing.

type Syncer

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

Syncer implements wallet synchronization services by over the Utopia wire protocol using Simplified Payment Verification (SPV) with compact filters.

func NewSyncer

func NewSyncer(w *wallet.Wallet, lp *p2p.LocalPeer) *Syncer

NewSyncer creates a Syncer that will sync the wallet using SPV.

func (*Syncer) GetBlocks

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

GetBlocks implements the GetBlocks method of the wallet.Peer interface.

func (*Syncer) GetCFilters

func (s *Syncer) GetCFilters(ctx context.Context, blockHashes []*chainhash.Hash) ([]*gcs.Filter, error)

GetCFilters implements the GetCFilters method of the wallet.Peer interface.

func (*Syncer) GetHeaders

func (s *Syncer) GetHeaders(ctx context.Context, blockLocators []*chainhash.Hash, hashStop *chainhash.Hash) ([]*wire.BlockHeader, error)

GetHeaders implements the GetHeaders method of the wallet.Peer interface.

func (*Syncer) LoadTxFilter

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

LoadTxFilter implements the LoadTxFilter method of the wallet.NetworkBackend interface.

func (*Syncer) PublishTransactions

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

PublishTransactions implements the PublishTransaction method of the wallet.Peer interface.

func (*Syncer) Rescan

func (s *Syncer) Rescan(ctx context.Context, blockHashes []chainhash.Hash, r wallet.RescanSaver) error

Rescan implements the Rescan method of the wallet.NetworkBackend interface.

func (*Syncer) Run

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

Run synchronizes the wallet, returning when synchronization fails or the context is cancelled.

func (*Syncer) SendFlashTxVote

func (s *Syncer) SendFlashTxVote(flashTxVote *wire.MsgFlashTxVote) error

func (*Syncer) SetNotifications

func (s *Syncer) SetNotifications(ntfns *Notifications)

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

func (*Syncer) SetPersistantPeers deprecated

func (s *Syncer) SetPersistantPeers(peers []string)

SetPersistantPeers sets each peer as a persistent peer and disables DNS seeding and peer discovery.

Deprecated: use SetPersistentPeers instead.

func (*Syncer) SetPersistentPeers

func (s *Syncer) SetPersistentPeers(peers []string)

SetPersistentPeers sets each peer as a persistent peer and disables DNS seeding and peer discovery.

func (*Syncer) StakeDifficulty

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

StakeDifficulty implements the StakeDifficulty method of the wallet.NetworkBackend interface.

This implementation of the method will always error as the stake difficulty is not queryable over wire protocol, and when the next stake difficulty is available in a header commitment, the wallet will be able to determine this itself without requiring the NetworkBackend.

func (*Syncer) String

func (s *Syncer) String() string

Jump to

Keyboard shortcuts

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