chain

package
v0.0.0-...-c45a497 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: ISC Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackendFromRPCClient

func BackendFromRPCClient(rpcClient *rpcclient.Client) wallet.NetworkBackend

BackendFromRPCClient creates a wallet network backend from an RPC client.

func DisableLog

func DisableLog()

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

func RPCClientFromBackend

func RPCClientFromBackend(n wallet.NetworkBackend) (*rpcclient.Client, error)

RPCClientFromBackend returns the RPC client used to create a wallet network backend. This errors if the backend was not created using BackendFromRPCClient.

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 Notifications

type Notifications struct {
	Synced                       func(sync 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()
}

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

type RPCClient

type RPCClient struct {
	*dcrrpcclient.Client
	// contains filtered or unexported fields
}

RPCClient represents a persistent client connection to a decred RPC server for information regarding the current best block chain.

func NewRPCClient

func NewRPCClient(chainParams *chaincfg.Params, connect, user, pass string, certs []byte,
	disableTLS bool) (*RPCClient, error)

NewRPCClient creates a direct client connection to the server described by the connect string. If disableTLS is false, the remote RPC certificate must be provided in the certs slice. The connection is not established immediately, but must be done using the Start method. If the remote server does not operate on the same decred network as described by the passed chain parameters, the connection will be disconnected. Deprecated: use NewRPCClientConfig

func NewRPCClientConfig

func NewRPCClientConfig(chainParams *chaincfg.Params, connConfig *dcrrpcclient.ConnConfig) (*RPCClient, error)

NewRPCClientConfig creates a client connection to the server described by the passed chainParams and connConfig

func (*RPCClient) POSTClient

func (c *RPCClient) POSTClient() (*dcrrpcclient.Client, error)

POSTClient creates the equivalent HTTP POST dcrrpcclient.Client.

func (*RPCClient) Start

func (c *RPCClient) Start(ctx context.Context, retry bool) (err error)

Start attempts to establish a client connection with the remote server. If successful, handler goroutines are started to process notifications sent by the server. After a limited number of connection attempts, this function gives up, and therefore will not block forever waiting for the connection to be established to a server that may not exist.

func (*RPCClient) Stop

func (c *RPCClient) Stop()

Stop disconnects the client and signals the shutdown of all goroutines started by Start.

func (*RPCClient) WaitForShutdown

func (c *RPCClient) WaitForShutdown()

WaitForShutdown blocks until both the client has finished disconnecting and all handlers have exited.

type RPCSyncer

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

RPCSyncer implements wallet synchronization services by processing notifications from a pfcd JSON-RPC server.

func NewRPCSyncer

func NewRPCSyncer(w *wallet.Wallet, rpcClient *RPCClient) *RPCSyncer

NewRPCSyncer creates an RPCSyncer that will sync the wallet using the RPC client.

func (*RPCSyncer) Run

func (s *RPCSyncer) Run(ctx context.Context, startupSync bool) 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 pfcd server are performed. Otherwise, it will listen for notifications but not register for any updates.

func (*RPCSyncer) SetNotifications

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

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

Jump to

Keyboard shortcuts

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