lightnode

package module
v0.0.0-...-1bfa4a9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 28 Imported by: 0

README ΒΆ

πŸš€ lightnode

Coverage Status

A node used for querying Darknodes using JSON-RPC 2.0 interfaces. Featuring query caching (for performance) as well as retrying for failed requests (for reliability).

Built with ❀ by Ren.

Building a Docker image

docker build . --build-arg GITHUB_TOKEN={your github token} --tag lightnode

Running a Docker image

Ensure you have a working local .env file for neccesary env vars set, then

docker run --env-file=.env --env DATABASE_URL=/lightnode/cache.sql --network host -v `pwd`/cache.sql:/lightnode/cache.sql lightnode

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	DefaultPort                      = "5000"
	DefaultCap                       = 128
	DefaultMaxBatchSize              = 10
	DefaultMaxPageSize               = 10
	DefaultMaxGatewayCount           = 10000
	DefaultServerTimeout             = 15 * time.Second
	DefaultClientTimeout             = 15 * time.Second
	DefaultTTL                       = 3 * time.Second
	DefaultUpdaterPollRate           = 5 * time.Minute
	DefaultConfirmerPollRate         = confirmer.DefaultPollInterval
	DefaultWatcherPollRate           = 15 * time.Second
	DefaultWatcherMaxBlockAdvance    = uint64(1000)
	DefaultWatcherConfidenceInterval = uint64(6)
	DefaultTransactionExpiry         = confirmer.DefaultExpiry
	DefaultBootstrapAddrs            = []wire.Address{}
	DefaultLimiterIPRates            = map[string]rate.Limit{"fallback": resolver.LimiterDefaultIPRate}
	DefaultLimiterGlobalRates        = map[string]rate.Limit{"fallback": resolver.LimiterDefaultGlobalRate}
	DefaultLimiterTTL                = resolver.LimiterDefaultTTL
	DefaultLimiterMaxClients         = resolver.LimiterDefaultMaxClients
)

Enumerate default options.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Lightnode ΒΆ

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

Lightnode is the top level container that encapsulates the functionality of the lightnode.

func New ΒΆ

func New(options Options, ctx context.Context, logger logrus.FieldLogger, sqlDB *sql.DB, client redis.Cmdable) Lightnode

New constructs a new Lightnode.

func (Lightnode) Run ΒΆ

func (lightnode Lightnode) Run(ctx context.Context)

Run starts the `Lightnode`. This function call is blocking.

type Options ΒΆ

type Options struct {
	Network                   multichain.Network
	DistPubKey                *id.PubKey
	Port                      string
	Cap                       int
	MaxBatchSize              int
	MaxPageSize               int
	MaxGatewayCount           int
	ServerTimeout             time.Duration
	ClientTimeout             time.Duration
	TTL                       time.Duration
	UpdaterPollRate           time.Duration
	ConfirmerPollRate         time.Duration
	WatcherPollRate           time.Duration
	WatcherMaxBlockAdvance    uint64
	WatcherConfidenceInterval uint64
	TransactionExpiry         time.Duration
	BootstrapAddrs            []wire.Address
	Chains                    map[multichain.Chain]binding.ChainOptions
	Whitelist                 []tx.Selector
	LimiterGlobalRates        map[string]rate.Limit
	LimiterIPRates            map[string]rate.Limit
	LimiterTTL                time.Duration
	LimiterMaxClients         int
}

Options to configure the precise behaviour of the Lightnode.

func DefaultOptions ΒΆ

func DefaultOptions() Options

DefaultOptions returns new options with default configurations that should work for the majority of use cases.

func (Options) WithBootstrapAddrs ΒΆ

func (opts Options) WithBootstrapAddrs(bootstrapAddrs []wire.Address) Options

WithBootstrapAddrs makes an initial list of nodes known to the node. These nodes will be used to bootstrap into the P2P network.

func (Options) WithCap ΒΆ

func (opts Options) WithCap(cap int) Options

WithCap updates the capacity.

func (Options) WithChains ΒΆ

func (opts Options) WithChains(chains map[multichain.Chain]binding.ChainOptions) Options

WithChains is used to specify the chain options for a the supported chains.

func (Options) WithClientTimeout ΒΆ

func (opts Options) WithClientTimeout(clientTimeout time.Duration) Options

WithClientTimeout updates the client timeout.

func (Options) WithConfirmerPollRate ΒΆ

func (opts Options) WithConfirmerPollRate(confirmerPollRate time.Duration) Options

WithConfirmerPollRate updates the confirmer poll rate.

func (Options) WithDistPubKey ΒΆ

func (opts Options) WithDistPubKey(distPubKey *id.PubKey) Options

WithDistPubKey updates the distributed public key.

func (Options) WithLimiterGlobalRates ΒΆ

func (opts Options) WithLimiterGlobalRates(rates map[string]rate.Limit) Options

WithLimiterGlobalRate is used to set global rate limits for specific methods

func (Options) WithLimiterIPRates ΒΆ

func (opts Options) WithLimiterIPRates(rates map[string]rate.Limit) Options

WithLimiterIpRate is used to set per-ip rate limits for specific methods

func (Options) WithLimiterMaxClients ΒΆ

func (opts Options) WithLimiterMaxClients(maxClients int) Options

WithLimiterMaxClients used to whitelist certain selectors inside the Darknode.

func (Options) WithLimiterTTL ΒΆ

func (opts Options) WithLimiterTTL(ttl time.Duration) Options

WithLimiterTTL used to whitelist certain selectors inside the Darknode.

func (Options) WithMaxBatchSize ΒΆ

func (opts Options) WithMaxBatchSize(maxBatchSize int) Options

WithMaxBatchSize updates the maximum batch size when submitting requests.

func (Options) WithMaxGatewayCount ΒΆ

func (opts Options) WithMaxGatewayCount(maxGatewayCount int) Options

WithMaxGatewayCount is used to set the max number of gateways that can be persisted

func (Options) WithMaxPageSize ΒΆ

func (opts Options) WithMaxPageSize(maxPageSize int) Options

WithMaxPageSize updates the maximum page size when querying transactions.

func (Options) WithNetwork ΒΆ

func (opts Options) WithNetwork(network multichain.Network) Options

WithNetwork updates the network.

func (Options) WithPort ΒΆ

func (opts Options) WithPort(port string) Options

WithPort updates the port.

func (Options) WithServerTimeout ΒΆ

func (opts Options) WithServerTimeout(serverTimeout time.Duration) Options

WithServerTimeout updates the server timeout.

func (Options) WithTTL ΒΆ

func (opts Options) WithTTL(ttl time.Duration) Options

WithTTL updates the time-to-live duration.

func (Options) WithTransactionExpiry ΒΆ

func (opts Options) WithTransactionExpiry(transactionExpiry time.Duration) Options

WithTransactionExpiry updates the transaction expiry.

func (Options) WithUpdaterPollRate ΒΆ

func (opts Options) WithUpdaterPollRate(updaterPollRate time.Duration) Options

WithUpdaterPollRate updates the updater poll rate.

func (Options) WithWatcherConfidenceInterval ΒΆ

func (opts Options) WithWatcherConfidenceInterval(watcherConfidenceInterval uint64) Options

WithWatcherPollRate updates the watcher poll rate.

func (Options) WithWatcherMaxBlockAdvance ΒΆ

func (opts Options) WithWatcherMaxBlockAdvance(watcherMaxBlockAdvance uint64) Options

WithWatcherPollRate updates the watcher poll rate.

func (Options) WithWatcherPollRate ΒΆ

func (opts Options) WithWatcherPollRate(watcherPollRate time.Duration) Options

WithWatcherPollRate updates the watcher poll rate.

func (Options) WithWhitelist ΒΆ

func (opts Options) WithWhitelist(whitelist []tx.Selector) Options

WithWhitelist is used to whitelist certain selectors inside the Darknode.

Directories ΒΆ

Path Synopsis
cmd
compat
v0
v1

Jump to

Keyboard shortcuts

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