sync

package
v0.7.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYNC_WORKERS = "SYNC_WORKERS"

	SYNC_MAX_IDLE_CONNECTIONS = "SYNC_MAX_IDLE_CONNECTIONS"
	SYNC_MAX_OPEN_CONNECTIONS = "SYNC_MAX_OPEN_CONNECTIONS"
	SYNC_MAX_CONN_LIFETIME    = "SYNC_MAX_CONN_LIFETIME"
)

Env variables

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DB       *postgres.DB
	DBConfig postgres.Config
	Workers  int64
	WSClient *rpc.Client
	NodeInfo node.Info
}

Config struct

func NewConfig

func NewConfig() (*Config, error)

NewConfig is used to initialize a sync config from a .toml file

type Indexer

type Indexer interface {
	// APIs(), Protocols(), Start() and Stop()
	ethnode.Lifecycle
	APIs() []rpc.API
	Protocols() []p2p.Protocol
	// Data processing event loop
	Sync(wg *sync.WaitGroup) error
	// Method to access chain type
	Chain() shared.ChainType
}

Indexer is the top level interface for streaming, converting to IPLDs, publishing, and indexing all chain data at head This service is compatible with the Ethereum service interface (node.Service)

func NewIndexerService

func NewIndexerService(settings *Config) (Indexer, error)

NewIndexer creates a new Indexer using an underlying Service struct

type Service

type Service struct {
	// Interface for streaming payloads over an rpc subscription
	Streamer eth.Streamer
	// Interface for transforming raw payloads into IPLD object models in Postgres
	Transformer eth.Transformer
	// Chan the processor uses to subscribe to payloads from the Streamer
	PayloadChan chan statediff.Payload
	// Used to signal shutdown of the service
	QuitChan chan bool
	// Number of sync workers
	Workers int64
	// chain type for this service
	ChainConfig *params.ChainConfig
}

Service is the underlying struct for the indexer

func (*Service) APIs

func (sap *Service) APIs() []rpc.API

APIs returns the RPC descriptors the indexer service offers

func (*Service) Chain

func (sap *Service) Chain() shared.ChainType

Chain returns the chain type for this service

func (*Service) Protocols

func (sap *Service) Protocols() []p2p.Protocol

Protocols exports the services p2p protocols, this service has none

func (*Service) Start

func (sap *Service) Start() error

Start is used to begin the service This is mostly just to satisfy the node.Service interface

func (*Service) Stop

func (sap *Service) Stop() error

Stop is used to close down the service This is mostly just to satisfy the node.Service interface

func (*Service) Sync

func (sap *Service) Sync(wg *sync.WaitGroup) error

Sync streams incoming raw chain data and converts it for further processing It forwards the converted data to the publish process(es) it spins up This continues on no matter if or how many subscribers there are

Jump to

Keyboard shortcuts

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