Implement getrawmempool rpc message
This commit is contained in:
parent
71d669c0b9
commit
41c6ed8b6f
@ -56,6 +56,17 @@ type resGetBlockCount struct {
|
|||||||
Result uint32 `json:"result"`
|
Result uint32 `json:"result"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getrawmempool
|
||||||
|
|
||||||
|
type cmdGetMempool struct {
|
||||||
|
Method string `json:"method"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type resGetMempool struct {
|
||||||
|
Error *RPCError `json:"error"`
|
||||||
|
Result []string `json:"result"`
|
||||||
|
}
|
||||||
|
|
||||||
// getblockheader
|
// getblockheader
|
||||||
|
|
||||||
type cmdGetBlockHeader struct {
|
type cmdGetBlockHeader struct {
|
||||||
@ -308,6 +319,23 @@ func (b *BitcoinRPC) GetBlockFull(hash string) (*Block, error) {
|
|||||||
return &res.Result, nil
|
return &res.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMempool returns transactions in mempool.
|
||||||
|
func (b *BitcoinRPC) GetMempool() ([]string, error) {
|
||||||
|
glog.V(1).Info("rpc: getrawmempool")
|
||||||
|
|
||||||
|
res := resGetMempool{}
|
||||||
|
req := cmdGetMempool{Method: "getrawmempool"}
|
||||||
|
err := b.call(&req, &res)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if res.Error != nil {
|
||||||
|
return nil, res.Error
|
||||||
|
}
|
||||||
|
return res.Result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetTransaction returns a transaction by the transaction ID.
|
// GetTransaction returns a transaction by the transaction ID.
|
||||||
func (b *BitcoinRPC) GetTransaction(txid string) (*Tx, error) {
|
func (b *BitcoinRPC) GetTransaction(txid string) (*Tx, error) {
|
||||||
glog.V(1).Info("rpc: getrawtransaction ", txid)
|
glog.V(1).Info("rpc: getrawtransaction ", txid)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user