btcjson: Add getmempoolentry API
This commit is contained in:
parent
d552176e1d
commit
d9241e91a9
4 changed files with 49 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014 The btcsuite developers
|
// Copyright (c) 2014-2017 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -333,6 +333,19 @@ func NewGetInfoCmd() *GetInfoCmd {
|
||||||
return &GetInfoCmd{}
|
return &GetInfoCmd{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMempoolEntryCmd defines the getmempoolentry JSON-RPC command.
|
||||||
|
type GetMempoolEntryCmd struct {
|
||||||
|
TxID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGetMempoolEntryCmd returns a new instance which can be used to issue a
|
||||||
|
// getmempoolentry JSON-RPC command.
|
||||||
|
func NewGetMempoolEntryCmd(txHash string) *GetMempoolEntryCmd {
|
||||||
|
return &GetMempoolEntryCmd{
|
||||||
|
TxID: txHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command.
|
// GetMempoolInfoCmd defines the getmempoolinfo JSON-RPC command.
|
||||||
type GetMempoolInfoCmd struct{}
|
type GetMempoolInfoCmd struct{}
|
||||||
|
|
||||||
|
@ -741,6 +754,7 @@ func init() {
|
||||||
MustRegisterCmd("getgenerate", (*GetGenerateCmd)(nil), flags)
|
MustRegisterCmd("getgenerate", (*GetGenerateCmd)(nil), flags)
|
||||||
MustRegisterCmd("gethashespersec", (*GetHashesPerSecCmd)(nil), flags)
|
MustRegisterCmd("gethashespersec", (*GetHashesPerSecCmd)(nil), flags)
|
||||||
MustRegisterCmd("getinfo", (*GetInfoCmd)(nil), flags)
|
MustRegisterCmd("getinfo", (*GetInfoCmd)(nil), flags)
|
||||||
|
MustRegisterCmd("getmempoolentry", (*GetMempoolEntryCmd)(nil), flags)
|
||||||
MustRegisterCmd("getmempoolinfo", (*GetMempoolInfoCmd)(nil), flags)
|
MustRegisterCmd("getmempoolinfo", (*GetMempoolInfoCmd)(nil), flags)
|
||||||
MustRegisterCmd("getmininginfo", (*GetMiningInfoCmd)(nil), flags)
|
MustRegisterCmd("getmininginfo", (*GetMiningInfoCmd)(nil), flags)
|
||||||
MustRegisterCmd("getnetworkinfo", (*GetNetworkInfoCmd)(nil), flags)
|
MustRegisterCmd("getnetworkinfo", (*GetNetworkInfoCmd)(nil), flags)
|
||||||
|
|
|
@ -383,6 +383,19 @@ func TestChainSvrCmds(t *testing.T) {
|
||||||
marshalled: `{"jsonrpc":"1.0","method":"getinfo","params":[],"id":1}`,
|
marshalled: `{"jsonrpc":"1.0","method":"getinfo","params":[],"id":1}`,
|
||||||
unmarshalled: &btcjson.GetInfoCmd{},
|
unmarshalled: &btcjson.GetInfoCmd{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "getmempoolentry",
|
||||||
|
newCmd: func() (interface{}, error) {
|
||||||
|
return btcjson.NewCmd("getmempoolentry", "txhash")
|
||||||
|
},
|
||||||
|
staticCmd: func() interface{} {
|
||||||
|
return btcjson.NewGetMempoolEntryCmd("txhash")
|
||||||
|
},
|
||||||
|
marshalled: `{"jsonrpc":"1.0","method":"getmempoolentry","params":["txhash"],"id":1}`,
|
||||||
|
unmarshalled: &btcjson.GetMempoolEntryCmd{
|
||||||
|
TxID: "txhash",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "getmempoolinfo",
|
name: "getmempoolinfo",
|
||||||
newCmd: func() (interface{}, error) {
|
newCmd: func() (interface{}, error) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2014 The btcsuite developers
|
// Copyright (c) 2014-2017 The btcsuite developers
|
||||||
// Use of this source code is governed by an ISC
|
// Use of this source code is governed by an ISC
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
@ -166,6 +166,25 @@ type GetBlockTemplateResult struct {
|
||||||
RejectReasion string `json:"reject-reason,omitempty"`
|
RejectReasion string `json:"reject-reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMempoolEntryResult models the data returned from the getmempoolentry
|
||||||
|
// command.
|
||||||
|
type GetMempoolEntryResult struct {
|
||||||
|
Size int32 `json:"size"`
|
||||||
|
Fee float64 `json:"fee"`
|
||||||
|
ModifiedFee float64 `json:"modifiedfee"`
|
||||||
|
Time int64 `json:"time"`
|
||||||
|
Height int64 `json:"height"`
|
||||||
|
StartingPriority float64 `json:"startingpriority"`
|
||||||
|
CurrentPriority float64 `json:"currentpriority"`
|
||||||
|
DescendantCount int64 `json:"descendantcount"`
|
||||||
|
DescendantSize int64 `json:"descendantsize"`
|
||||||
|
DescendantFees float64 `json:"descendantfees"`
|
||||||
|
AncestorCount int64 `json:"ancestorcount"`
|
||||||
|
AncestorSize int64 `json:"ancestorsize"`
|
||||||
|
AncestorFees float64 `json:"ancestorfees"`
|
||||||
|
Depends []string `json:"depends"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetMempoolInfoResult models the data returned from the getmempoolinfo
|
// GetMempoolInfoResult models the data returned from the getmempoolinfo
|
||||||
// command.
|
// command.
|
||||||
type GetMempoolInfoResult struct {
|
type GetMempoolInfoResult struct {
|
||||||
|
|
|
@ -222,6 +222,7 @@ var rpcUnimplemented = map[string]struct{}{
|
||||||
"estimatefee": {},
|
"estimatefee": {},
|
||||||
"estimatepriority": {},
|
"estimatepriority": {},
|
||||||
"getchaintips": {},
|
"getchaintips": {},
|
||||||
|
"getmempoolentry": {},
|
||||||
"getnetworkinfo": {},
|
"getnetworkinfo": {},
|
||||||
"getwork": {},
|
"getwork": {},
|
||||||
"invalidateblock": {},
|
"invalidateblock": {},
|
||||||
|
|
Loading…
Reference in a new issue