Documentation
¶
Index ¶
- Constants
- Variables
- type AccountProcessor
- type BaseProcessor
- func (bp *BaseProcessor) ApplyConfig(cfg *config.Config) error
- func (bp *BaseProcessor) CallGetRestEndPoint(address string, path string, value interface{}) error
- func (bp *BaseProcessor) CallPostRestEndPoint(address string, path string, data interface{}, response interface{}) error
- func (bp *BaseProcessor) ComputeShardId(addressBuff []byte) (uint32, error)
- func (bp *BaseProcessor) GetObservers(shardId uint32) ([]*data.Observer, error)
- type Processor
- type TransactionProcessor
Constants ¶
const AddressPath = "/address/"
AddressPath defines the address path at which the nodes answer
const TransactionPath = "/transaction/send"
TransactionPath defines the address path at which the nodes answer
Variables ¶
var ErrEmptyObserversList = errors.New("empty observers list provided")
ErrEmptyObserversList signals that an empty list of observers has been provided
var ErrMissingObserver = errors.New("missing observer")
ErrMissingObserver signals that no observers have been provided for provided shard ID
var ErrNilAddressConverter = errors.New("nil address converter")
ErrNilAddressConverter signals that a nil address converter has been provided
var ErrNilConfig = errors.New("nil configuration provided")
ErrNilConfig signals that a nil config has been provided
var ErrNilCoreProcessor = errors.New("nil core processor")
ErrNilCoreProcessor signals that a nil core processor has been provided
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