Documentation
¶
Index ¶
- Variables
- type AddrUxoutResult
- type Client
- func (c *Client) Do(obj interface{}, method string, params interface{}) error
- func (c *Client) GetAddressUxOuts(addrs []string) ([]AddrUxoutResult, error)
- func (c *Client) GetBlocks(start, end uint64) (*visor.ReadableBlocks, error)
- func (c *Client) GetBlocksBySeq(ss []uint64) (*visor.ReadableBlocks, error)
- func (c *Client) GetLastBlocks(n uint64) (*visor.ReadableBlocks, error)
- func (c *Client) GetStatus() (*StatusResult, error)
- func (c *Client) GetTransactionByID(txid string) (*TxnResult, error)
- func (c *Client) GetUnspentOutputs(addrs []string) (*OutputsResult, error)
- func (c *Client) InjectTransaction(tx *coin.Transaction) (string, error)
- func (c *Client) InjectTransactionString(rawtx string) (string, error)
- type Config
- type Gatewayer
- type HandlerFunc
- type OutputsResult
- type RPCError
- type Request
- type Response
- type StatusResult
- type TxIDJson
- type TxnResult
- type WebRPC
Constants ¶
This section is empty.
Variables ¶
var ErrJSONUnmarshal = errors.New("JSON unmarshal failed")
ErrJSONUnmarshal is returned if JSON unmarshal fails
Functions ¶
This section is empty.
Types ¶
type AddrUxoutResult ¶
type AddrUxoutResult struct {
Address string `json:"address"`
UxOuts []*historydb.UxOutJSON `json:"uxouts"`
}
AddrUxoutResult the address uxout json format
type Client ¶
type Client struct {
Addr string
// contains filtered or unexported fields
}
Client is an RPC client
func (*Client) GetAddressUxOuts ¶
func (c *Client) GetAddressUxOuts(addrs []string) ([]AddrUxoutResult, error)
GetAddressUxOuts returns unspent outputs for a set of addresses TODO -- what is the difference between this and GetUnspentOutputs?
func (*Client) GetBlocks ¶
func (c *Client) GetBlocks(start, end uint64) (*visor.ReadableBlocks, error)
GetBlocks returns a range of blocks
func (*Client) GetBlocksBySeq ¶
func (c *Client) GetBlocksBySeq(ss []uint64) (*visor.ReadableBlocks, error)
GetBlocksBySeq returns blocks for a set of block sequences (heights)
func (*Client) GetLastBlocks ¶
func (c *Client) GetLastBlocks(n uint64) (*visor.ReadableBlocks, error)
GetLastBlocks returns the last n blocks
func (*Client) GetStatus ¶
func (c *Client) GetStatus() (*StatusResult, error)
GetStatus returns status info for a spo node
func (*Client) GetTransactionByID ¶
GetTransactionByID returns a transaction given a txid
func (*Client) GetUnspentOutputs ¶
func (c *Client) GetUnspentOutputs(addrs []string) (*OutputsResult, error)
GetUnspentOutputs returns unspent outputs for a set of addresses TODO -- what is the difference between this and GetAddressUxOuts?
func (*Client) InjectTransaction ¶
func (c *Client) InjectTransaction(tx *coin.Transaction) (string, error)
InjectTransaction injects a *coin.Transaction to the network
type Config ¶
type Config struct {
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
WorkerNum uint
ChanBuffSize uint // size of ops channel
}
Config configures the WebRPC
type Gatewayer ¶
type Gatewayer interface {
GetLastBlocks(num uint64) (*visor.ReadableBlocks, error)
GetBlocks(start, end uint64) (*visor.ReadableBlocks, error)
GetBlocksInDepth(vs []uint64) (*visor.ReadableBlocks, error)
GetUnspentOutputs(filters ...daemon.OutputsFilter) (*visor.ReadableOutputSet, error)
GetTransaction(txid cipher.SHA256) (*visor.Transaction, error)
InjectBroadcastTransaction(tx coin.Transaction) error
GetAddrUxOuts(addr []cipher.Address) ([]*historydb.UxOut, error)
GetTimeNow() uint64
}
Gatewayer provides interfaces for getting spo related info.
type HandlerFunc ¶
HandlerFunc represents the function type for processing the request
type OutputsResult ¶
type OutputsResult struct {
Outputs visor.ReadableOutputSet `json:"outputs"`
}
OutputsResult the output json format
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data string `json:"data,omitempty"`
}
RPCError response error
type Request ¶
type Request struct {
ID string `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request rpc request struct
func NewRequest ¶
NewRequest create new webrpc request.
func (*Request) DecodeParams ¶
DecodeParams decodes request params to specific value.
type Response ¶
type Response struct {
ID *string `json:"id"`
Jsonrpc string `json:"jsonrpc"`
Error *RPCError `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
Response rpc response struct
type StatusResult ¶
type StatusResult struct {
Running bool `json:"running"`
BlockNum uint64 `json:"num_of_blocks"`
LastBlockHash string `json:"hash_of_last_block"`
TimeSinceLastBlock string `json:"time_since_last_block"`
}
StatusResult result struct of get_status
type TxIDJson ¶
type TxIDJson struct {
Txid string `json:"txid"`
}
TxIDJson wraps txid with json tags
type TxnResult ¶
type TxnResult struct {
Transaction *visor.TransactionResult `json:"transaction"`
}
TxnResult wraps the visor.TransactionResult
type WebRPC ¶
type WebRPC struct {
Addr string // service address
Gateway Gatewayer
WorkerNum uint
ChanBuffSize uint // size of ops channel
// contains filtered or unexported fields
}
WebRPC manage the web rpc state and handles
func (*WebRPC) HandleFunc ¶
func (rpc *WebRPC) HandleFunc(method string, h HandlerFunc) error
HandleFunc registers handler function