ledgerclient

package
v0.0.0-...-9742f5a Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_SYNC_INTERVAL = 10

DEFAULT_SYNC_INTERVAL is the number of seconds between RPC calls to retrieve new blocks

Variables

This section is empty.

Functions

This section is empty.

Types

type Replicator

type Replicator struct {
	GrpcClient ccmsg.LedgerClient
	// contains filtered or unexported fields
}

Replicator replicates the ledger from the central server to a local data store, calling back to subscribers on every block.

func NewReplicator

func NewReplicator(l *logrus.Logger, storage *ledger.Database, addr string, insecure bool) (*Replicator, error)

NewReplicator creates a new replicator replicating into `persistence` from `addr`.

func (*Replicator) FetchBlocks

func (r *Replicator) FetchBlocks(ctx context.Context) error

FetchBlocks queries new blocks from the ledger

func (*Replicator) IsSynced

func (r *Replicator) IsSynced(ctx context.Context) (bool, error)

IsSynced queries the ledger for the highest blocked and compares that to the local DB to report whether the chain is up to date or not. 'synced' is poorly defined for a distributed system, but here it means that this local database has replicated all the information that the ledger it is connected to has to give it.

func (*Replicator) SyncChain

func (r *Replicator) SyncChain(ctx context.Context, syncInterval time.Duration)

SyncChain starts a loop that queries new blocks periodically until ctx is cancelled

Jump to

Keyboard shortcuts

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