synchronizernode

package
v0.0.0-...-54b74c5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_DELAY = 3 * time.Second
View Source
const DefaultBatchSize = 50
View Source
const LIMIT = uint64(50)

Variables

This section is empty.

Functions

func FormatTransactionId

func FormatTransactionId(txId []byte) string

nolint

func NewSynchronizerCreateWorker

func NewSynchronizerCreateWorker(
	inputRepository *repository.InputRepository,
	inputRefRepository *repository.RawInputRefRepository,
	dbRawUrl string,
	rawRepository *RawRepository,
	synchronizerUpdate *SynchronizerUpdate,
	decoder *decoder.OutputDecoder,
	synchronizerReport *SynchronizerReport,
	synchronizerOutputUpdate *SynchronizerOutputUpdate,
	outputRefRepository *repository.RawOutputRefRepository,
	synchronizerOutputCreate *SynchronizerOutputCreate,
	synchronizerCreateInput *SynchronizerInputCreator,
	synchronizerOutputExecuted *SynchronizerOutputExecuted,
) supervisor.Worker

Types

type AbiDecoder

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

func NewAbiDecoder

func NewAbiDecoder(abi *abi.ABI) *AbiDecoder

func (AbiDecoder) GetMapRaw

func (s AbiDecoder) GetMapRaw(rawData []byte) (map[string]any, error)

type FilterID

type FilterID struct {
	IDgt uint64
}

type FilterInput

type FilterInput struct {
	IDgt         uint64
	IsStatusNone bool
	Status       string
}

type FilterOutput

type FilterOutput struct {
	IDgt                uint64
	HaveTransactionHash bool
}

type Output

type Output struct {
	ID                   uint64    `db:"id"`
	Index                string    `db:"index"`
	InputIndex           string    `db:"input_index"`
	RawData              []byte    `db:"raw_data"`
	Hash                 []byte    `db:"hash,omitempty"`
	OutputHashesSiblings []byte    `db:"output_hashes_siblings,omitempty"`
	InputID              uint64    `db:"input_id"`
	TransactionHash      []byte    `db:"transaction_hash,omitempty"`
	UpdatedAt            time.Time `db:"updated_at"`
	AppContract          []byte    `db:"app_contract"`
}

type Pagination

type Pagination struct {
	Limit uint64
}

type RawInput

type RawInput struct {
	ID                 uint64    `db:"id"`
	Index              uint64    `db:"index"` // numeric(20,0)
	RawData            []byte    `db:"raw_data"`
	BlockNumber        uint64    `db:"block_number"` // numeric(20,0)
	Status             string    `db:"status"`
	MachineHash        []byte    `db:"machine_hash,omitempty"`
	OutputsHash        []byte    `db:"outputs_hash,omitempty"`
	ApplicationAddress []byte    `db:"application_address"`
	EpochID            uint64    `db:"epoch_id"`
	TransactionId      []byte    `db:"transaction_id"`
	UpdatedAt          time.Time `db:"updated_at"`
}

type RawRepository

type RawRepository struct {
	Db *sqlx.DB
	// contains filtered or unexported fields
}

func NewRawRepository

func NewRawRepository(connectionURL string, db *sqlx.DB) *RawRepository

func (*RawRepository) FindAllInputsByFilter

func (s *RawRepository) FindAllInputsByFilter(ctx context.Context, filter FilterInput, pag *Pagination) ([]RawInput, error)

func (*RawRepository) FindAllOutputsByFilter

func (s *RawRepository) FindAllOutputsByFilter(ctx context.Context, filter FilterID) ([]Output, error)

func (*RawRepository) FindAllOutputsExecutedAfter

func (s *RawRepository) FindAllOutputsExecutedAfter(ctx context.Context, afterUpdatedAt time.Time, rawId uint64) ([]Output, error)

func (*RawRepository) FindAllOutputsWithProof

func (s *RawRepository) FindAllOutputsWithProof(ctx context.Context, filter FilterID) ([]Output, error)

func (*RawRepository) FindAllReportsByFilter

func (s *RawRepository) FindAllReportsByFilter(ctx context.Context, filter FilterID) ([]Report, error)

func (*RawRepository) FindInputByOutput

func (s *RawRepository) FindInputByOutput(ctx context.Context, filter FilterID) (*RawInput, error)

type Report

type Report struct {
	ID          int64  `db:"id"`
	Index       string `db:"index"`
	InputIndex  string `db:"input_index"`
	RawData     []byte `db:"raw_data"`
	InputID     int64  `db:"input_id"`
	AppContract []byte `db:"app_contract"`
}

type RosettaStatusRef

type RosettaStatusRef struct {
	RawStatus string
	Status    model.CompletionStatus
}

func GetStatusRosetta

func GetStatusRosetta() []RosettaStatusRef

type SynchronizerCreateWorker

type SynchronizerCreateWorker struct {
	SynchronizerReport         *SynchronizerReport
	DbRawUrl                   string
	RawRepository              *RawRepository
	SynchronizerUpdate         *SynchronizerUpdate
	Decoder                    *decoder.OutputDecoder
	SynchronizerOutputUpdate   *SynchronizerOutputUpdate
	SynchronizerOutputCreate   *SynchronizerOutputCreate
	SynchronizerCreateInput    *SynchronizerInputCreator
	SynchronizerOutputExecuted *SynchronizerOutputExecuted
	// contains filtered or unexported fields
}

func (SynchronizerCreateWorker) Start

func (s SynchronizerCreateWorker) Start(ctx context.Context, ready chan<- struct{}) error

Start implements supervisor.Worker.

func (SynchronizerCreateWorker) String

func (s SynchronizerCreateWorker) String() string

String implements supervisor.Worker.

func (SynchronizerCreateWorker) WatchNewInputs

func (s SynchronizerCreateWorker) WatchNewInputs(stdCtx context.Context) error

type SynchronizerInputCreator

type SynchronizerInputCreator struct {
	InputRepository       *repository.InputRepository
	RawInputRefRepository *repository.RawInputRefRepository
	RawNodeV2Repository   *RawRepository
	AbiDecoder            *AbiDecoder
}

func NewSynchronizerInputCreator

func NewSynchronizerInputCreator(
	inputRepository *repository.InputRepository,
	rawInputRefRepository *repository.RawInputRefRepository,
	rawRepository *RawRepository,
	abiDecoder *AbiDecoder,
) *SynchronizerInputCreator

func (*SynchronizerInputCreator) CreateInput

func (s *SynchronizerInputCreator) CreateInput(ctx context.Context, rawInput RawInput) error

func (*SynchronizerInputCreator) GetAdvanceInputFromMap

func (s *SynchronizerInputCreator) GetAdvanceInputFromMap(rawInput RawInput) (*model.AdvanceInput, error)

func (SynchronizerInputCreator) SyncInputs

func (s SynchronizerInputCreator) SyncInputs(ctx context.Context) error

type SynchronizerOutputCreate

type SynchronizerOutputCreate struct {
	VoucherRepository      *repository.VoucherRepository
	NoticeRepository       *repository.NoticeRepository
	RawNodeV2Repository    *RawRepository
	RawOutputRefRepository *repository.RawOutputRefRepository
	AbiDecoder             *AbiDecoder
}

func NewSynchronizerOutputCreate

func NewSynchronizerOutputCreate(
	voucherRepository *repository.VoucherRepository,
	noticeRepository *repository.NoticeRepository,
	rawRepository *RawRepository,
	rawOutputRefRepository *repository.RawOutputRefRepository,
	abiDecoder *AbiDecoder,
) *SynchronizerOutputCreate

func (*SynchronizerOutputCreate) CreateOutput

func (s *SynchronizerOutputCreate) CreateOutput(ctx context.Context, rawOutputRef *repository.RawOutputRef, rawOutput Output) error

func (*SynchronizerOutputCreate) GetConvenienceNotice

func (s *SynchronizerOutputCreate) GetConvenienceNotice(rawOutput Output) (*model.ConvenienceNotice, error)

func (*SynchronizerOutputCreate) GetConvenienceVoucher

func (s *SynchronizerOutputCreate) GetConvenienceVoucher(rawOutput Output) (*model.ConvenienceVoucher, error)

func (*SynchronizerOutputCreate) GetRawOutputRef

func (s *SynchronizerOutputCreate) GetRawOutputRef(rawOutput Output) (*repository.RawOutputRef, error)

func (*SynchronizerOutputCreate) SyncOutputs

func (s *SynchronizerOutputCreate) SyncOutputs(ctx context.Context) error

type SynchronizerOutputExecuted

type SynchronizerOutputExecuted struct {
	VoucherRepository      *repository.VoucherRepository
	NoticeRepository       *repository.NoticeRepository
	RawNodeV2Repository    *RawRepository
	RawOutputRefRepository *repository.RawOutputRefRepository
}

func NewSynchronizerOutputExecuted

func NewSynchronizerOutputExecuted(
	voucherRepository *repository.VoucherRepository,
	noticeRepository *repository.NoticeRepository,
	rawRepository *RawRepository,
	rawOutputRefRepository *repository.RawOutputRefRepository,
) *SynchronizerOutputExecuted

func (*SynchronizerOutputExecuted) SyncOutputsExecution

func (s *SynchronizerOutputExecuted) SyncOutputsExecution(ctx context.Context) error

func (*SynchronizerOutputExecuted) UpdateExecutionData

func (s *SynchronizerOutputExecuted) UpdateExecutionData(
	ctx context.Context,
	rawOutput Output,
) error

type SynchronizerOutputUpdate

type SynchronizerOutputUpdate struct {
	VoucherRepository      *repository.VoucherRepository
	NoticeRepository       *repository.NoticeRepository
	RawNodeV2Repository    *RawRepository
	RawOutputRefRepository *repository.RawOutputRefRepository
}

func NewSynchronizerOutputUpdate

func NewSynchronizerOutputUpdate(
	voucherRepository *repository.VoucherRepository,
	noticeRepository *repository.NoticeRepository,
	rawRepository *RawRepository,
	rawOutputRefRepository *repository.RawOutputRefRepository,
) *SynchronizerOutputUpdate

func (*SynchronizerOutputUpdate) SyncOutputs

func (s *SynchronizerOutputUpdate) SyncOutputs(ctx context.Context) error

func (*SynchronizerOutputUpdate) UpdateProof

func (s *SynchronizerOutputUpdate) UpdateProof(
	ctx context.Context,
	rawOutput Output,
	hashes []string,
) error

type SynchronizerReport

type SynchronizerReport struct {
	ReportRepository *repository.ReportRepository
	RawRepository    *RawRepository
}

func NewSynchronizerReport

func NewSynchronizerReport(
	reportRepository *repository.ReportRepository,
	rawRepository *RawRepository,
) *SynchronizerReport

func (*SynchronizerReport) SyncReports

func (s *SynchronizerReport) SyncReports(ctx context.Context) error

type SynchronizerUpdate

type SynchronizerUpdate struct {
	DbRawUrl              string
	RawNode               *RawRepository
	RawInputRefRepository *repository.RawInputRefRepository
	InputRepository       *repository.InputRepository
	BatchSize             int
}

func NewSynchronizerUpdate

func NewSynchronizerUpdate(
	rawInputRefRepository *repository.RawInputRefRepository,
	rawNode *RawRepository,
	inputRepository *repository.InputRepository,
) SynchronizerUpdate

func (*SynchronizerUpdate) SyncInputStatus

func (s *SynchronizerUpdate) SyncInputStatus(ctx context.Context) error

Jump to

Keyboard shortcuts

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