process

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AddressPath = "/address/"

AddressPath defines the address path at which the nodes answer

View Source
const TransactionPath = "/transaction/send"

TransactionPath defines the address path at which the nodes answer

Variables

View Source
var ErrEmptyObserversList = errors.New("empty observers list provided")

ErrEmptyObserversList signals that an empty list of observers has been provided

View Source
var ErrMissingObserver = errors.New("missing observer")

ErrMissingObserver signals that no observers have been provided for provided shard ID

View Source
var ErrNilAddressConverter = errors.New("nil address converter")

ErrNilAddressConverter signals that a nil address converter has been provided

View Source
var ErrNilConfig = errors.New("nil configuration provided")

ErrNilConfig signals that a nil config has been provided

View Source
var ErrNilCoreProcessor = errors.New("nil core processor")

ErrNilCoreProcessor signals that a nil core processor has been provided

View Source
var ErrSendingRequest = errors.New("sending request error")

ErrSendingRequest signals that sending the request failed on all observers

Functions

This section is empty.

Types

type AccountProcessor

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

AccountProcessor is able to process account requests

func NewAccountProcessor

func NewAccountProcessor(proc Processor) (*AccountProcessor, error)

NewAccountProcessor creates a new instance of AccountProcessor

func (*AccountProcessor) GetAccount

func (ap *AccountProcessor) GetAccount(address string) (*data.Account, error)

GetAccount resolves the request by sending the request to the right observer and replies back the answer

type BaseProcessor

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

BaseProcessor represents an implementation of CoreProcessor that helps processing requests

func NewBaseProcessor

func NewBaseProcessor(addressConverter state.AddressConverter) (*BaseProcessor, error)

NewBaseProcessor creates a new instance of BaseProcessor struct

func (*BaseProcessor) ApplyConfig

func (bp *BaseProcessor) ApplyConfig(cfg *config.Config) error

ApplyConfig applies a config on a base processor

func (*BaseProcessor) CallGetRestEndPoint

func (bp *BaseProcessor) CallGetRestEndPoint(
	address string,
	path string,
	value interface{},
) error

CallGetRestEndPoint calls an external end point (sends a request on a node)

func (*BaseProcessor) CallPostRestEndPoint

func (bp *BaseProcessor) CallPostRestEndPoint(
	address string,
	path string,
	data interface{},
	response interface{},
) error

CallPostRestEndPoint calls an external end point (sends a request on a node)

func (*BaseProcessor) ComputeShardId

func (bp *BaseProcessor) ComputeShardId(addressBuff []byte) (uint32, error)

ComputeShardId computes the shard id in which the account resides

func (*BaseProcessor) GetObservers

func (bp *BaseProcessor) GetObservers(shardId uint32) ([]*data.Observer, error)

GetObservers returns the registered observers on a shard

type Processor

type Processor interface {
	ApplyConfig(cfg *config.Config) error
	GetObservers(shardId uint32) ([]*data.Observer, error)
	ComputeShardId(addressBuff []byte) (uint32, error)
	CallGetRestEndPoint(address string, path string, value interface{}) error
	CallPostRestEndPoint(address string, path string, data interface{}, response interface{}) error
}

Processor defines what a processor should be able to do

type TransactionProcessor

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

TransactionProcessor is able to process transaction requests

func NewTransactionProcessor

func NewTransactionProcessor(proc Processor) (*TransactionProcessor, error)

NewTransactionProcessor creates a new instance of TransactionProcessor

func (*TransactionProcessor) SendTransaction

func (ap *TransactionProcessor) SendTransaction(nonce uint64, sender string, receiver string, value *big.Int, code string, signature []byte) (string, error)

SendTransaction relay the post request by sending the request to the right observer and replies back the answer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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