data

package
v0.18.15 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParamNotFound  = errors.New("param not found")
	ErrWrongParamType = errors.New("wrong param type")
)

Functions

This section is empty.

Types

type ContractData

type ContractData struct {
	Address []byte
	Data    map[string]interface{}
}

func NewContractData

func NewContractData(address []byte) *ContractData

NewContractData returns a pointer to a new ContractData object. It takes an address as an input.

func (*ContractData) Get

func (data *ContractData) Get(key string) interface{}

func (*ContractData) Update

func (data *ContractData) Update(d map[string]interface{}) error

func (*ContractData) UpdateByJSONData

func (data *ContractData) UpdateByJSONData(in []byte) error

func (*ContractData) Validate

func (data *ContractData) Validate(address []byte) bool

type ExtStore added in v0.16.1

type ExtStore interface {
	WithState(*storage.State) ExtStore
}

type Request

type Request struct {
	Query  string                 // the query method
	Data   []byte                 // data stored as a serialized byte array
	Params map[string]interface{} // request params as a map of string to interface
}
Request

Request generic request object for Query handling. Request comes with its query string and parameters

func NewRequest

func NewRequest(query string, params map[string]interface{}) (*Request, error)

NewRequest creates a new request with given BTCParams.

func NewRequestFromData

func NewRequestFromData(query string, dat []byte) *Request

NewRequestFromData creates a new request object from a byte array

func NewRequestFromObj

func NewRequestFromObj(query string, obj interface{}) (*Request, error)

NewRequestFromObj creates a new request object from an arguments struct passed. It serializes the argument struct object for a client channel and sets it against an argname. You can check example argument structs in client/request.

func (*Request) ClientDeserialize

func (r *Request) ClientDeserialize(name string, obj interface{}) error

func (*Request) GetBool

func (r *Request) GetBool(key string) (bool, error)

func (*Request) GetBytes

func (r *Request) GetBytes(key string) []byte

GetBytes retrieves a byte array

func (*Request) GetFloat64

func (r *Request) GetFloat64(key string) float64

func (*Request) GetInt

func (r *Request) GetInt(key string) int

func (*Request) GetString

func (r *Request) GetString(key string) string

GetString retrieves a string parameter saved in a request object. If a string parameter is not set or the object type of the parameter is not string an empty string is returned. All calling instances are required to check and handle empty string.

func (*Request) Parse

func (r *Request) Parse()

Parse parses the serialized parameters data and saves it to BTCParams

type Response

type Response struct {
	Data     []byte `json:"data"`
	ErrorMsg string `json:"errorMsg,omitempty"`
	Success  bool   `json:"success"`
}

Response

func (*Response) Error

func (r *Response) Error(msg string)

func (*Response) JSON

func (r *Response) JSON(a interface{}) (err error)

func (*Response) SetData

func (r *Response) SetData(dat []byte)

func (*Response) SetDataObj

func (r *Response) SetDataObj(obj interface{}) error

type Router added in v0.14.3

type Router interface {
	Add(Type, ExtStore) error
	Get(Type) (ExtStore, error)
}

Router interface supplies functionality to add a store to the Data package.

type StorageRouter added in v0.14.3

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

func NewStorageRouter added in v0.14.3

func NewStorageRouter() StorageRouter

func (StorageRouter) Add added in v0.14.3

func (s StorageRouter) Add(storeType Type, storeObj ExtStore) error

Add a new store to the router

func (StorageRouter) Get added in v0.14.3

func (s StorageRouter) Get(storeType Type) (ExtStore, error)

Get the structure of store ,using the Type

func (*StorageRouter) WithState added in v0.16.1

func (s *StorageRouter) WithState(state *storage.State) *StorageRouter

type Type added in v0.14.3

type Type string

Jump to

Keyboard shortcuts

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