mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-12 18:56:48 +01:00
Switch over to new btcjson.GetRawMempoolResult.
Rather than using a type specifically in btcd for the getrawmempool, this commit, along with a recent commit to btcjson, changes the code over to use the type from btcjson. This is more consistent with other RPC results and provides a few extra benefits such as the ability for btcjson to automatically unmarshal the results into a concrete type with proper field types as opposed to a generic interface.
This commit is contained in:
parent
41da7ae606
commit
66e93f5163
1 changed files with 2 additions and 15 deletions
17
rpcserver.go
17
rpcserver.go
|
@ -1082,28 +1082,15 @@ func handleGetPeerInfo(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||||
return s.server.PeerInfo(), nil
|
return s.server.PeerInfo(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// mempoolDescriptor describes a JSON object which is returned for each
|
|
||||||
// transaction in the memory pool in response to a getrawmempool command with
|
|
||||||
// the verbose flag set.
|
|
||||||
type mempoolDescriptor struct {
|
|
||||||
Size int `json:"size"`
|
|
||||||
Fee float64 `json:"fee"`
|
|
||||||
Time int64 `json:"time"`
|
|
||||||
Height int64 `json:"height"`
|
|
||||||
StartingPriority int `json:"startingpriority"`
|
|
||||||
CurrentPriority int `json:"currentpriority"`
|
|
||||||
Depends []string `json:"depends"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// handleGetRawMempool implements the getrawmempool command.
|
// handleGetRawMempool implements the getrawmempool command.
|
||||||
func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||||
c := cmd.(*btcjson.GetRawMempoolCmd)
|
c := cmd.(*btcjson.GetRawMempoolCmd)
|
||||||
descs := s.server.txMemPool.TxDescs()
|
descs := s.server.txMemPool.TxDescs()
|
||||||
|
|
||||||
if c.Verbose {
|
if c.Verbose {
|
||||||
result := make(map[string]*mempoolDescriptor, len(descs))
|
result := make(map[string]*btcjson.GetRawMempoolResult, len(descs))
|
||||||
for _, desc := range descs {
|
for _, desc := range descs {
|
||||||
mpd := &mempoolDescriptor{
|
mpd := &btcjson.GetRawMempoolResult{
|
||||||
Size: desc.Tx.MsgTx().SerializeSize(),
|
Size: desc.Tx.MsgTx().SerializeSize(),
|
||||||
Fee: float64(desc.Fee) /
|
Fee: float64(desc.Fee) /
|
||||||
float64(btcutil.SatoshiPerBitcoin),
|
float64(btcutil.SatoshiPerBitcoin),
|
||||||
|
|
Loading…
Add table
Reference in a new issue