chain

package
v0.0.0-...-47c3d23 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: ISC Imports: 19 Imported by: 0

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 {
	*rpcclient.Client
	// contains filtered or unexported fields
}

RPCClient represents a persistent client connection to a utopia 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 utopia network as described by the passed chain parameters, the connection will be disconnected. Deprecated: use NewRPCClientConfig

func NewRPCClientConfig

func NewRPCClientConfig(chainParams *chaincfg.Params, connConfig *rpcclient.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() (*rpcclient.Client, error)

POSTClient creates the equivalent HTTP POST rpcclient.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 ucd 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 ucd 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