sync

package
v0.0.0-...-c736a29 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameStorePath    = "/store/nameservice/key"
	AuctionStorePath = "/store/auction/key"
)
View Source
const AggressiveSyncIntervalInMillis = 250

AggressiveSyncIntervalInMillis is the interval for aggressive sync, to catch up quickly to the current height.

View Source
const DefaultLightNodeHome = "$HOME/.wire/dxnsd-lite"

DefaultLightNodeHome is the root directory for the dxnsd-lite node.

View Source
const DiscoverRPCNodesFrequencyMillis = 60 * 1000

DiscoverRPCNodesFrequencyMillis controls frequency to discover new RPC endpoints.

View Source
const DumpRPCNodeStatsFrequencyMillis = 60 * 1000

DumpRPCNodeStatsFrequencyMillis controls frequency to dump RPC node stats.

View Source
const ErrorWaitDurationMillis = 1 * 1000

ErrorWaitDurationMillis is the wait duration in case of errors.

View Source
const SyncIntervalInMillis = 5 * 1000

SyncIntervalInMillis is the interval for initiating incremental sync, when already caught up to current height.

View Source
const SyncLaggingMinHeightDiff = 5

SyncLaggingMinHeightDiff is the min. difference in height to consider a lite node as lagging the full node.

Variables

This section is empty.

Functions

func CreateVerifier

func CreateVerifier(config *Config) tmlite.Verifier

CreateVerifier creates a light client verifier.

func DiscoverRPCEndpoints

func DiscoverRPCEndpoints(ctx *Context, gqlEndpoint string) ([]string, error)

DiscoverRPCEndpoints queries for WNS RPC endpoints.

func ErrVerifyCommit

func ErrVerifyCommit(height int64) error

ErrVerifyCommit returns a common error reflecting that the blockchain commit at a given height can't be verified. The reason is that the base checkpoint of the certifier is newer than the given height

func Init

func Init(ctx *Context, height int64)

Init sets up the lite node.

func Start

func Start(ctx *Context)

Start initiates the sync process.

func Verify

func Verify(ctx *Context, height int64) (tmtypes.SignedHeader, error)

Verify verifies the consensus proof at given height.

func VerifyProof

func VerifyProof(ctx *Context, queryPath string, resp abci.ResponseQuery) error

VerifyProof verifies the ABCI response.

Types

type AppState

type AppState struct {
	Nameservice nameservice.GenesisState `json:"nameservice" yaml:"nameservice"`
}

AppState is used to import initial app state (records, names) into the db.

type Config

type Config struct {
	LogLevel            string
	NodeAddress         string
	ChainID             string
	Home                string
	InitFromNode        bool
	InitFromGenesisFile bool
	Endpoint            string
	SyncTimeoutMins     int
}

Config represents config for sync functionality.

type Context

type Context struct {

	// Primary RPC PrimaryNode, used for verification.
	PrimaryNode *RPCNodeHandler
	// contains filtered or unexported fields
}

Context contains sync context info.

func NewContext

func NewContext(config *Config) *Context

NewContext creates a context object.

type GenesisState

type GenesisState struct {
	ChainID  string   `json:"chain_id" yaml:"chain_id"`
	AppState AppState `json:"app_state" yaml:"app_state"`
}

GenesisState is used to import initial state into the db.

type Keeper

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

Keeper is an impl. of an interface similar to the nameservice Keeper.

func NewKeeper

func NewKeeper(ctx *Context) *Keeper

NewKeeper creates a new keeper.

func (Keeper) GetAuction

func (k Keeper) GetAuction(id auction.ID) *auction.Auction

GetAuction get the auction record.

func (Keeper) GetBids

func (k Keeper) GetBids(id auction.ID) []*auction.Bid

GetBids get the auction bids.

func (Keeper) GetChainID

func (k Keeper) GetChainID() string

GetChainID gets the chain ID.

func (Keeper) GetNameAuthority

func (k Keeper) GetNameAuthority(name string) *ns.NameAuthority

GetNameAuthority get the name authority record for an authority name.

func (Keeper) GetNameRecord

func (k Keeper) GetNameRecord(name string) *ns.NameRecord

GetNameRecord get the name record for a name/WRN.

func (Keeper) GetRecord

func (k Keeper) GetRecord(id ns.ID) ns.Record

GetRecord - gets a record from the store.

func (Keeper) GetStatusRecord

func (k Keeper) GetStatusRecord() Status

GetStatusRecord gets the sync status record.

func (Keeper) HasRecord

func (k Keeper) HasRecord(id ns.ID) bool

HasRecord - checks if a record by the given ID exists.

func (Keeper) HasStatusRecord

func (k Keeper) HasStatusRecord() bool

HasStatusRecord checks if the store has a status record.

func (Keeper) MatchRecords

func (k Keeper) MatchRecords(matchFn func(*ns.Record) bool) []*ns.Record

MatchRecords - get all matching records.

func (Keeper) PutRecord

func (k Keeper) PutRecord(record ns.RecordObj)

PutRecord - saves a record to the store and updates ID -> Record index.

func (Keeper) ResolveWRN

func (k Keeper) ResolveWRN(wrn string) *ns.Record

ResolveWRN resolves a WRN to a record.

func (Keeper) SaveAuction

func (k Keeper) SaveAuction(auctionObj auction.Auction)

SaveAuction - saves an auction record.

func (Keeper) SaveBid

func (k Keeper) SaveBid(bid auction.Bid)

SaveBid - saves an auction bid.

func (Keeper) SaveStatus

func (k Keeper) SaveStatus(status Status)

SaveStatus saves the sync status record.

func (Keeper) SetNameAuthorityRecord

func (k Keeper) SetNameAuthorityRecord(name string, nameAuthority ns.NameAuthority)

SetNameAuthorityRecord - sets a name authority record.

func (Keeper) SetNameRecord

func (k Keeper) SetNameRecord(wrn string, nameRecord ns.NameRecord)

SetNameRecord - sets a name record.

func (Keeper) SetNameRecordRaw

func (k Keeper) SetNameRecordRaw(wrn string, nameRecord ns.NameRecord)

SetNameRecordRaw - sets a name record (used during intial sync).

type RPCNodeHandler

type RPCNodeHandler struct {
	Address      string          `json:"address"`
	Client       *rpcclient.HTTP `json:"-"`
	Calls        int64           `json:"calls"`
	Errors       int64           `json:"errors"`
	LastCalledAt time.Time       `json:"lastCalledAt"`
}

RPCNodeHandler is used to call an RPC endpoint and maintains basic stats.

func NewRPCNodeHandler

func NewRPCNodeHandler(nodeAddress string) *RPCNodeHandler

NewRPCNodeHandler instantiates a new RPC node handler.

type Response

type Response struct {
	Records []gql.Record `json:"records"`
}

Response represents the GQL response.

type Status

type Status struct {
	LastSyncedHeight int64
	CatchingUp       bool
}

Status represents the sync status of the node.

Jump to

Keyboard shortcuts

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