client

package
v0.0.1-rc5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIntegrityCheckFailed = errors.New("integrity check failed")
View Source
var SelfCheck = true

SelfCheck Flag describing should manager check anyway the latest version for network it has

Functions

func InitMetrics

func InitMetrics()

Types

type Client

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

func NewClient

func NewClient(storeEng store.DataStore, logger *zap.Logger, runner *Runner) *Client

func (*Client) CheckMissingTransactions

func (hc *Client) CheckMissingTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, window uint64) (missingBlocks, missingTransactions [][2]uint64, err error)

CheckMissingTransactions checks consistency of database if every transaction is written correctly (all blocks + correct transaction number from blocks)

func (*Client) GetMissingTransactions

func (hc *Client) GetMissingTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, window uint64, async bool, force bool) (run *Run, err error)

GetMissingTransactions gets missing transactions for given height range using CheckMissingTransactions. This may run very very long (aka synchronize entire chain). For that kind of operations async parameter got added and runner was created.

func (*Client) GetRunningTransactions

func (hc *Client) GetRunningTransactions(ctx context.Context) (run []Run, err error)

GetRunningTransactions gets running transactions

func (*Client) GetTransaction

func (hc *Client) GetTransaction(ctx context.Context, nv NetworkVersion, id string) ([]shared.Transaction, error)

func (*Client) GetTransactions

func (hc *Client) GetTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, batchLimit uint64, silent bool) ([]shared.Transaction, error)

GetTransactions gets transaction range and stores it in the database with respective blocks

func (*Client) InsertTransactions

func (hc *Client) InsertTransactions(ctx context.Context, nv NetworkVersion, readr io.ReadCloser) error

InsertTransactions inserts external transactions batch

func (*Client) LinkSender

func (hc *Client) LinkSender(sender TaskSender)

func (*Client) ScrapeLatest

func (hc *Client) ScrapeLatest(ctx context.Context, ldr shared.LatestDataRequest) (ldResp shared.LatestDataResponse, er error)

ScrapeLatest scrapes latest data using the latest known block from database

func (*Client) SearchTransactions

func (hc *Client) SearchTransactions(ctx context.Context, ts shared.TransactionSearch) ([]shared.Transaction, error)

SearchTransactions is the search

type ClientContractor

type ClientContractor interface {
	SchedulerContractor
	ControllContractor

	SearchTransactions(ctx context.Context, ts shared.TransactionSearch) ([]shared.Transaction, error)
	GetTransaction(ctx context.Context, nv NetworkVersion, id string) ([]shared.Transaction, error)
	GetTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, batchLimit uint64, silent bool) ([]shared.Transaction, error)
}

ClientContractor a format agnostic

type ControllContractor

type ControllContractor interface {
	InsertTransactions(ctx context.Context, nv NetworkVersion, read io.ReadCloser) error

	CheckMissingTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, window uint64) (missingBlocks, missingTransactions [][2]uint64, err error)
	GetMissingTransactions(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange, window uint64, async bool, force bool) (run *Run, err error)

	GetRunningTransactions(ctx context.Context) (run []Run, err error)
}

type NetworkVersion

type NetworkVersion struct {
	Network string
	ChainID string
	Version string
}

type Progresser

type Progresser interface {
	Report(done shared.HeightRange, duration time.Duration, err []error, finished bool)
}

Progresser is interface that allows to report progress

type ReqOut

type ReqOut struct {
	Run []Run `json:"runs"`
	Err error `json:"error"`
}

type Run

type Run struct {
	sync.Mutex `json:"-"`

	NV          NetworkVersion     `json:"nv"`
	HeightRange shared.HeightRange `json:"height_range"`

	Ctx    context.Context    `json:"-"`
	Cancel context.CancelFunc `json:"-"`

	Progress []RunProgress `json:"run_progress"`

	Success bool `json:"success"`

	Finished         bool      `json:"finished"`
	StartedTime      time.Time `json:"started_time"`
	FinishTime       time.Time `json:"finished_time"`
	LastProgressTime time.Time `json:"last_progress_time"`
}

Run is process handler

func NewRun

func NewRun(ctx context.Context, nv NetworkVersion, heightRange shared.HeightRange) *Run

NewRun is Run constructor

func (*Run) Report

func (r *Run) Report(done shared.HeightRange, duration time.Duration, err []error, finished bool)

Report reports progress of certain process

func (*Run) Stop

func (r *Run) Stop()

Stop stops.

type RunProgress

type RunProgress struct {
	Done   shared.HeightRange `json:"done"`
	D      time.Duration      `json:"duration"`
	T      time.Time          `json:"time"`
	Errors []error            `json:"errors"`
}

RunProgress info

type RunReq

type RunReq struct {
	Kind        string //Type
	NV          NetworkVersion
	HeightRange shared.HeightRange

	Force bool
	Resp  chan RunResp
}

RunReq async task structure

type RunResp

type RunResp struct {
	IsNew bool
	Run   *Run
	Err   error
}

type Runner

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

Runner is a runner for async long running process.

Sometimes there is a need to run process asynchronously. Runner serves as a simple manager for NetworkVersion pairs

func NewRunner

func NewRunner() *Runner

NewRunner is Runner constructor

func (*Runner) GetRunning

func (r *Runner) GetRunning() ReqOut

func (*Runner) Run

func (r *Runner) Run()

func (*Runner) StartProcess

func (r *Runner) StartProcess(nv NetworkVersion, heightRange shared.HeightRange, force bool) (bool, *Run, error)

StartProcess starts task waiting until task will be started then return it's reference.

func (*Runner) StopProcess

func (r *Runner) StopProcess(nv NetworkVersion, heightRange shared.HeightRange) error

StopProcess stops task

type SchedulerContractor

type SchedulerContractor interface {
	ScrapeLatest(ctx context.Context, ldr shared.LatestDataRequest) (ldResp shared.LatestDataResponse, er error)
}

type TaskSender

type TaskSender interface {
	Send([]structs.TaskRequest) (*structs.Await, error)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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