validator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package validator represents a helper methods useful for validators in the Polaris network. Methods in the validator package are specified in terms of a validator interface, that of which is also implemented in the validator package.

Package validator represents a helper methods useful for validators in the Polaris network. Methods in the validator package are specified in terms of a validator interface, that of which is also implemented in the validator package.

Index

Constants

View Source
const (
	// BeaconDagValidatorValidationProtocol represents the validation protocol of the beacon dag validator.
	BeaconDagValidatorValidationProtocol = "beacon_simple_sig_ver"
)

Variables

View Source
var (
	// ErrInvalidTransactionHash is an error definition representing a transaction hash of invalid value.
	ErrInvalidTransactionHash = errors.New("transaction hash is invalid")

	//ErrInvalidTransactionTimestamp is an error definition representing a transaction timestamp of invalid value.
	ErrInvalidTransactionTimestamp = errors.New("invalid transaction timestamp")

	// ErrInvalidTransactionSignature is an error definition representing a transaction signature of invalid value.
	ErrInvalidTransactionSignature = errors.New("invalid transaction signature")

	// ErrInsufficientSenderBalance is an error definition representing a sender balance of insufficient value.
	ErrInsufficientSenderBalance = errors.New("insufficient sender balance")

	// ErrDuplicateTransaction is an error definition representing a transaction of duplicate value in the working dag.
	ErrDuplicateTransaction = errors.New("transaction already exists in the working dag (duplicate)")

	// ErrInvalidTransactionDepth is an error definition representing a transaction of invalid depth value.
	ErrInvalidTransactionDepth = errors.New("invalid transaction depth (not best transaction)")

	// ErrInvalidNonce is an error definition representing a transaction of invalid nonce value.
	ErrInvalidNonce = errors.New("invalid transaction nonce")
)

Functions

This section is empty.

Types

type BeaconDagValidator

type BeaconDagValidator struct {
	Config *config.DagConfig `json:"config"` // Config represents the beacon dag config

	WorkingDag *types.Dag `json:"dag"` // Working validator dag
}

BeaconDagValidator represents a main dag validator.

func NewBeaconDagValidator

func NewBeaconDagValidator(config *config.DagConfig, workingDag *types.Dag) *BeaconDagValidator

NewBeaconDagValidator initializes a new beacon dag with a given config and working dag.

func (*BeaconDagValidator) GetWorkingConfig

func (validator *BeaconDagValidator) GetWorkingConfig() *config.DagConfig

GetWorkingConfig attempts to fetch the working config instance.

func (*BeaconDagValidator) GetWorkingDag

func (validator *BeaconDagValidator) GetWorkingDag() *types.Dag

GetWorkingDag attempts to fetch the working dag instance.

func (*BeaconDagValidator) ValidateTransaction

func (validator *BeaconDagValidator) ValidateTransaction(transaction *types.Transaction) error

ValidateTransaction validates the given transaction, transaction via the standard beacon dag validator. Each validation issue is returned as an error.

func (*BeaconDagValidator) ValidateTransactionDepth

func (validator *BeaconDagValidator) ValidateTransactionDepth(transaction *types.Transaction) bool

ValidateTransactionDepth checks that a given transaction's parent hash is a member of the last edge.

func (*BeaconDagValidator) ValidateTransactionHash

func (validator *BeaconDagValidator) ValidateTransactionHash(transaction *types.Transaction) bool

ValidateTransactionHash checks that a given transaction's hash is equivalent to the calculated hash of that given transaction.

func (*BeaconDagValidator) ValidateTransactionIsNotDuplicate

func (validator *BeaconDagValidator) ValidateTransactionIsNotDuplicate(transaction *types.Transaction) bool

ValidateTransactionIsNotDuplicate checks that a given transaction does not already exist in the working dag.

func (*BeaconDagValidator) ValidateTransactionNonce

func (validator *BeaconDagValidator) ValidateTransactionNonce(transaction *types.Transaction) bool

ValidateTransactionNonce checks that a given transaction's nonce is equivalent to the sending account's last nonce + 1.

func (*BeaconDagValidator) ValidateTransactionSenderBalance

func (validator *BeaconDagValidator) ValidateTransactionSenderBalance(transaction *types.Transaction) bool

ValidateTransactionSenderBalance checks that a given transaction's sender has a balance greater than or equal to the transaction's total value (including gas costs).

func (*BeaconDagValidator) ValidateTransactionSignature

func (validator *BeaconDagValidator) ValidateTransactionSignature(transaction *types.Transaction) bool

ValidateTransactionSignature validates the given transaction's signature against the transaction sender's public key. If the transaction's signature is nil, false is returned.

func (*BeaconDagValidator) ValidateTransactionTimestamp

func (validator *BeaconDagValidator) ValidateTransactionTimestamp(transaction *types.Transaction) bool

ValidateTransactionTimestamp validates the given transaction's timestamp against that of its parents. If the timestamp of any one of the given transaction's parents is after the given transaction's timestamp, false is returned. If any one of the transaction's parent transactions cannot be found in the working dag, false is returned.

func (*BeaconDagValidator) ValidationProtocol

func (validator *BeaconDagValidator) ValidationProtocol() string

ValidationProtocol fetches the current validator's validation protocol.

type Validator

type Validator interface {
	ValidateTransaction(transaction *types.Transaction) error // Validate a given transaction

	ValidateTransactionHash(transaction *types.Transaction) bool // Validate a given transaction's hash

	ValidateTransactionTimestamp(transaction *types.Transaction) bool // Validate a given transaction's timestamp

	ValidateTransactionSignature(transaction *types.Transaction) bool // Validate a given transaction's signature

	ValidateTransactionSenderBalance(transaction *types.Transaction) bool // Validate a given transaction's sender has

	ValidateTransactionIsNotDuplicate(transaction *types.Transaction) bool // Validate that a given transaction does not already exist in the working dag

	ValidateTransactionDepth(transaction *types.Transaction) bool // Validate that a given transaction's parent is a current edge

	ValidateTransactionNonce(transaction *types.Transaction) bool // Validate that a given transaction's nonce is equivalent to the current account index + 1

	ValidationProtocol() string // Get the current validator's validation protocol

	GetWorkingDag() *types.Dag // Get current validator's working dag

	GetWorkingConfig() *config.DagConfig // Get current validator's working config
}

Validator represents any generic validator.

Jump to

Keyboard shortcuts

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