git.gammaspectra.live/P2Pool/consensus/v3@v3.8.0/monero/client/rpc/daemon/client.go (about) 1 package daemon 2 3 import ( 4 "context" 5 "io" 6 ) 7 8 // Requester is responsible for making concrete request to Monero's endpoints, 9 // i.e., either `jsonrpc` methods or those "raw" endpoints. 10 type Requester interface { 11 // JSONRPC is used for callind methods under `/json_rpc` that follow 12 // monero's `v2` response and error encapsulation. 13 // 14 JSONRPC( 15 ctx context.Context, method string, params, result interface{}, 16 ) error 17 18 // RawRequest is used for making a request to an arbitrary endpoint 19 // `endpoint` whose response (in JSON format) should be unmarshalled to 20 // `response`. 21 // 22 RawRequest( 23 ctx context.Context, 24 endpoint string, 25 params interface{}, 26 response interface{}, 27 ) error 28 29 // RawBinaryRequest is used for making a request to an arbitrary endpoint 30 // `endpoint` whose response will be returned (which MUST be closed in error = nil) 31 // 32 RawBinaryRequest( 33 ctx context.Context, 34 endpoint string, 35 body io.Reader, 36 ) (io.ReadCloser, error) 37 } 38 39 // Client provides access to the daemon's JSONRPC methods and regular 40 // endpoints. 41 type Client struct { 42 Requester 43 } 44 45 // NewClient instantiates a new client for interacting with monero's daemon 46 // api. 47 func NewClient(c Requester) *Client { 48 return &Client{ 49 Requester: c, 50 } 51 }