Documentation ¶
Index ¶
Constants ¶
const ( MethodGet = "get" MethodFileList = "file_list" MethodAccountList = "account_list" MethodStatus = "status" MethodResolve = "resolve" MethodClaimSearch = "claim_search" MethodPurchaseCreate = "purchase_create" MethodWalletBalance = "wallet_balance" MethodWalletSend = "wallet_send" MethodSyncApply = "sync_apply" ParamStreamingUrl = "streaming_url" ParamPurchaseReceipt = "purchase_receipt" )
const (
// AllMethodsHook is used as the first argument to Add*Hook to make it apply to all methods
AllMethodsHook = ""
)
Variables ¶
This section is empty.
Functions ¶
func MethodAcceptsWallet ¶
MethodAcceptsWallet returns true for methods that can accept wallet_id
func MethodRequiresWallet ¶
MethodRequiresWallet returns true for methods that require wallet_id
Types ¶
type Caller ¶
type Caller struct { // Preprocessor is applied to query before it's sent to the SDK. Preprocessor func(q *Query) // Cache stores cachable queries to improve performance Cache cache.QueryCache // contains filtered or unexported fields }
Caller patches through JSON-RPC requests from clients, doing pre/post-processing, account processing and validation.
func (*Caller) AddPostflightHook ¶ added in v0.14.4
AddPostflightHook adds query postflight hook function, allowing to amend the response before it gets sent back to the client or to modify log entry fields.
func (*Caller) AddPreflightHook ¶ added in v0.14.1
AddPreflightHook adds query preflight hook function, allowing to amend the query before it gets sent to the JSON-RPC server, with an option to return an early response, avoiding sending the query to JSON-RPC server altogether.
func (*Caller) Call ¶
func (c *Caller) Call(req *jsonrpc.RPCRequest) (*jsonrpc.RPCResponse, error)
Call method forwards a JSON-RPC request to the lbrynet server. It returns a response that is ready to be sent back to the JSON-RPC client as is.
type Hook ¶ added in v0.14.1
type Hook func(c *Caller, hctx *HookContext) (*jsonrpc.RPCResponse, error)
Hook is a function that can be applied to certain methods during preflight or postflight phase using context data about the client query being performed. Hooks can modify both query and response, as well as perform additional queries via supplied Caller. If nil is returned instead of *jsonrpc.RPCResponse, original response is returned.
type HookContext ¶ added in v0.14.4
type HookContext struct { Query *Query Response *jsonrpc.RPCResponse // contains filtered or unexported fields }
HookContext contains data about the query being performed. When supplied in the postflight stage, it will contain Response and LogEntry, otherwise those will be nil.
func (*HookContext) AddLogField ¶ added in v0.14.4
func (hc *HookContext) AddLogField(key string, value interface{})
AddLogField injects additional data into default post-query log entry
type Query ¶
type Query struct { Request *jsonrpc.RPCRequest WalletID string }
Query is a wrapper around client JSON-RPC query for easier (un)marshaling and processing.
func NewQuery ¶
func NewQuery(req *jsonrpc.RPCRequest, walletID string) (*Query, error)
NewQuery initializes Query object with JSON-RPC request supplied as bytes. The object is immediately usable and returns an error in case request parsing fails. If wallet_id is not empty, it will be added as a param to the query when the Caller calls it.
func (*Query) IsAuthenticated ¶ added in v0.14.4
IsAuthenticated returns true if query is performed by an authenticated user
func (*Query) ParamsAsMap ¶
ParamsAsMap returns query params converted to plain map.