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
|
||||
}
|
||||
|
||||
// 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.
|
||||
func handleGetRawMempool(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||
c := cmd.(*btcjson.GetRawMempoolCmd)
|
||||
descs := s.server.txMemPool.TxDescs()
|
||||
|
||||
if c.Verbose {
|
||||
result := make(map[string]*mempoolDescriptor, len(descs))
|
||||
result := make(map[string]*btcjson.GetRawMempoolResult, len(descs))
|
||||
for _, desc := range descs {
|
||||
mpd := &mempoolDescriptor{
|
||||
mpd := &btcjson.GetRawMempoolResult{
|
||||
Size: desc.Tx.MsgTx().SerializeSize(),
|
||||
Fee: float64(desc.Fee) /
|
||||
float64(btcutil.SatoshiPerBitcoin),
|
||||
|
|
Loading…
Add table
Reference in a new issue