requester

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTimeout = 32 * time.Second
	Digest         = "Digest"
	Signature      = "Signature"
	ContentType    = "Content-Type"
	JSONRPCVersion = "2.0"
)

Variables

This section is empty.

Functions

func GetResponseBodyContract added in v0.9.0

func GetResponseBodyContract(url string, postP ContractRequest, signature string) ([]byte, error)

GetResponseBodyContract makes request to contract and extracts body

func GetResponseBodyPlatform added in v0.9.0

func GetResponseBodyPlatform(url string, method string, params interface{}) ([]byte, error)

GetResponseBodyContract makes request to platform and extracts body

func GetSeed

func GetSeed(url string) (string, error)

GetSeed makes rpc request to node.getSeed method and extracts it

func MakeContractRequest added in v0.9.5

func MakeContractRequest(url string, postP ContractRequest, signature string) (*http.Request, error)

func MakeRequestWithSeed added in v0.9.5

func MakeRequestWithSeed(ctx context.Context, url string, userCfg *UserConfigJSON, params *Params, seed string) (*http.Request, error)

MakeRequestWithSeed creates request with provided url, user config, params and seed.

func Send

func Send(ctx context.Context, url string, userCfg *UserConfigJSON, params *Params) ([]byte, error)

Send first gets seed and after that makes target request

func SendWithSeed

func SendWithSeed(ctx context.Context, url string, userCfg *UserConfigJSON, params *Params, seed string) ([]byte, error)

SendWithSeed sends request with known seed

func SetTimeout added in v0.7.5

func SetTimeout(timeout uint)

func SetVerbose

func SetVerbose(verb bool)

SetVerbose switches on verbose mode

func Sign added in v0.9.0

func Sign(privateKey crypto.PrivateKey, data []byte) (string, error)

Types

type ContractRequest added in v0.9.0

type ContractRequest struct {
	Request
	Params Params `json:"params,omitempty"`
}

ContractRequest is a representation of request struct to api

type ContractResponse added in v0.9.0

type ContractResponse struct {
	Response
	Result *ContractResult `json:"result,omitempty"`
}

type ContractResult added in v0.9.0

type ContractResult struct {
	CallResult       interface{} `json:"callResult,omitempty"`
	RequestReference string      `json:"requestReference,omitempty"`
	TraceID          string      `json:"traceID,omitempty"`
}

type Data added in v0.9.0

type Data struct {
	Trace            []string `json:"trace,omitempty"`
	TraceID          string   `json:"traceID,omitempty"`
	RequestReference string   `json:"requestReference,omitempty"`
}

type Error added in v0.9.0

type Error struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Data    Data   `json:"data,omitempty"`
}

func (*Error) Error added in v0.9.1

func (e *Error) Error() string

type InfoResponse

type InfoResponse struct {
	RootDomain             string   `json:"rootDomain"`
	RootMember             string   `json:"rootMember"`
	MigrationAdminMember   string   `json:"migrationAdminMember"`
	FeeMember              string   `json:"feeMember"`
	MigrationDaemonMembers []string `json:"migrationDaemonMembers"`
	NodeDomain             string   `json:"nodeDomain"`
	TraceID                string   `json:"traceID"`
}

InfoResponse represents response from rpc on network.getInfo method

func Info

func Info(url string) (*InfoResponse, error)

Info makes rpc request to network.getInfo method and extracts it

type Node added in v0.9.0

type Node struct {
	Reference string `json:"reference"`
	Role      string `json:"role"`
	IsWorking bool   `json:"isWorking"`
	ID        uint32 `json:"id"`
}

type Params added in v0.9.0

type Params struct {
	Seed       string      `json:"seed"`
	CallSite   string      `json:"callSite"`
	CallParams interface{} `json:"callParams,omitempty"`
	Reference  string      `json:"reference"`
	PublicKey  string      `json:"publicKey"`
	LogLevel   interface{} `json:"logLevel,omitempty"`
	Test       string      `json:"test,omitempty"`
}

func ReadRequestParamsFromFile added in v0.9.0

func ReadRequestParamsFromFile(path string) (*Params, error)

ReadRequestParamsFromFile read request config from file

type PlatformRequest added in v0.9.0

type PlatformRequest struct {
	Request
	PlatformParams interface{} `json:"params"`
	LogLevel       string      `json:"logLevel,omitempty"`
}

PlatformRequest represents params struct

type Request added in v0.9.0

type Request struct {
	Version string `json:"jsonrpc"`
	ID      uint64 `json:"id"`
	Method  string `json:"method"`
}

type Response added in v0.9.0

type Response struct {
	JSONRPC string `json:"jsonrpc"`
	ID      uint64 `json:"id"`
	Error   *Error `json:"error,omitempty"`
}

type SeedReply added in v0.9.0

type SeedReply struct {
	Seed    []byte `json:"seed"`
	TraceID string `json:"traceID"`
}

SeedReply is reply for Seed service requests.

type StatusResponse added in v0.7.5

type StatusResponse struct {
	NetworkState       string    `json:"networkState"`
	Origin             Node      `json:"origin"`
	ActiveListSize     int       `json:"activeListSize"`
	WorkingListSize    int       `json:"workingListSize"`
	Nodes              []Node    `json:"nodes"`
	PulseNumber        uint32    `json:"pulseNumber"`
	NetworkPulseNumber uint32    `json:"networkPulseNumber"`
	Entropy            []byte    `json:"entropy"`
	Version            string    `json:"version"`
	Timestamp          time.Time `json:"timestamp"`
	StartTime          time.Time `json:"startTime"`
}

StatusResponse represents response from rpc on node.getStatus method

func Status added in v0.7.5

func Status(url string) (*StatusResponse, error)

Status makes rpc request to node.getStatus method and extracts it

type UserConfigJSON

type UserConfigJSON struct {
	PrivateKey string `json:"private_key"`
	PublicKey  string `json:"public_key"`
	Caller     string `json:"caller"`
	// contains filtered or unexported fields
}

UserConfigJSON holds info about user

func CreateUserConfig

func CreateUserConfig(caller string, privKey string, publicKey string) (*UserConfigJSON, error)

CreateUserConfig creates user config from arguments

func ReadUserConfigFromFile

func ReadUserConfigFromFile(file string) (*UserConfigJSON, error)

ReadUserConfigFromFile read user config from file

Jump to

Keyboard shortcuts

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