core

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorLog *log.Logger

ErrorLog is used while the validator is running.

View Source
var ValidatorCmd *cobra.Command

ValidatorCmd is the account validator utility.

Functions

func CallProcessor

func CallProcessor(processor Processor, input string, config Params, results chan<- Result)

CallProcessor invokes the processor with a retry mechanism. Accepted input formats: 1: "(b64 or not encoded address)" 2: "address,(b64 or not encoded address)" 3: "box,(appid),(b64 encoded box name)"

func Start

func Start(work <-chan string, processorID ProcessorID, threads int, config Params, results chan<- Result)

Start runs the validator with data from work and puts results in results.

Types

type DynamicProcessor

type DynamicProcessor struct {
}

DynamicProcessor implements process address by dynamically normalizing the JSON and ensuring the results are equal.

func (DynamicProcessor) ProcessAddress

func (gp DynamicProcessor) ProcessAddress(algodData, indexerData []byte) (Result, error)

ProcessAddress is the entrypoint for the DynamicProcessor's address comparator.

func (DynamicProcessor) ProcessBox

func (gp DynamicProcessor) ProcessBox(algodData, indexerData []byte) (Result, error)

ProcessBox is the entrypoint for the DynamicProcessor's box comparator.

type ErrorDetails

type ErrorDetails struct {
	Resource string
	Address  string
	Appid    string
	Boxname  string
	Algod    string
	Indexer  string
	Diff     []string
}

ErrorDetails are additional details attached to a result in the event of an error.

type Params

type Params struct {
	AlgodURL     string
	AlgodToken   string
	IndexerURL   string
	IndexerToken string
	Retries      int
	RetryDelayMS int
}

Params are the program arguments which need to be passed between objects.

type Processor

type Processor interface {
	ProcessAddress(algodData []byte, indexerData []byte) (Result, error)
	ProcessBox(algodData []byte, indexerData []byte) (Result, error)
}

Processor is the algorithm to fetch and compare data from indexer and algod

func MakeProcessor

func MakeProcessor(id ProcessorID) (Processor, error)

MakeProcessor initializes the Processor from a ProcessorID

type ProcessorID

type ProcessorID int

ProcessorID is used to select which processor to use for validation.

const (
	Struct ProcessorID = iota
	Dynamic
	Default = Struct
)

ProcessorIDs

type Result

type Result struct {
	// Error is set if there were errors running the test.
	Error      error
	SameRound  bool
	SkipReason Skip

	Equal   bool
	Retries int
	Details *ErrorDetails
}

Result is the output of ProcessAddress.

type Skip

type Skip string

Skip indicates why something was skipped.

const (
	// NotSkipped is the default value indicated the results are not skipped.
	NotSkipped          Skip = ""
	SkipLimitReached    Skip = "account-limit"
	SkipAccountNotFound Skip = "missing-account"
	SkipBoxNotFound     Skip = "box-not-found"
	SkipBoxFailedLookup Skip = "box-failed-lookup"
	SkipBoxWrongAppid   Skip = "box-wrong-appid"
	SkipBoxMultiple     Skip = "box-multiple-boxes"
	SkipBoxWrongBox     Skip = "box-wrong-box"
)

constants relating to different skip cases

type StructProcessor

type StructProcessor struct {
}

StructProcessor implements the process function by serializing API responses into structs and comparing the typed objects to each other directly.

func (StructProcessor) ProcessAddress

func (gp StructProcessor) ProcessAddress(algodData, indexerData []byte) (Result, error)

ProcessAddress is the entrypoint for the StructProcessor's account comparator

func (StructProcessor) ProcessBox

func (gp StructProcessor) ProcessBox(algodData, indexerData []byte) (Result, error)

ProcessBox is the entrypoint for the StructProcessor's box comparator

Jump to

Keyboard shortcuts

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