requester

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT, Apache-2.0 Imports: 20 Imported by: 1

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

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

GetResponseBodyContract makes request to contract and extracts body

func GetResponseBodyPlatform

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

GetResponseBodyPlatform 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

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

func MakeRequestWithSeed

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

func SetTimeout(timeout uint)

func SetVerbose

func SetVerbose(verb bool)

SetVerbose switches on verbose mode

func Sign

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

Types

type ContractRequest

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

ContractRequest is a representation of request struct to api

type ContractResponse

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

type ContractResult

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

type Data

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

type Error

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

func (*Error) Error

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

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

type Params

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

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

ReadRequestParamsFromFile read request config from file

type PlatformRequest

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

PlatformRequest represents params struct

type Request

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

type Response

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

type SeedReply

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

SeedReply is reply for Seed service requests.

type StatusResponse

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

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