Browse Source

rpc: num_unconfirmed_txs (avoid sending txs back)

pull/205/head
Ethan Buchman 9 years ago
parent
commit
df25a22469
2 changed files with 14 additions and 0 deletions
  1. +5
    -0
      rpc/core/mempool.go
  2. +9
    -0
      rpc/core/routes.go

+ 5
- 0
rpc/core/mempool.go View File

@ -39,3 +39,8 @@ func UnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error) {
txs := mempoolReactor.Mempool.Reap(0) txs := mempoolReactor.Mempool.Reap(0)
return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil
} }
func NumUnconfirmedTxs() (*ctypes.ResultUnconfirmedTxs, error) {
txs := mempoolReactor.Mempool.Reap()
return &ctypes.ResultUnconfirmedTxs{len(txs), txs[:0]}, nil
}

+ 9
- 0
rpc/core/routes.go View File

@ -22,6 +22,7 @@ var Routes = map[string]*rpc.RPCFunc{
"broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSyncResult, "tx"), "broadcast_tx_sync": rpc.NewRPCFunc(BroadcastTxSyncResult, "tx"),
"broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsyncResult, "tx"), "broadcast_tx_async": rpc.NewRPCFunc(BroadcastTxAsyncResult, "tx"),
"unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""), "unconfirmed_txs": rpc.NewRPCFunc(UnconfirmedTxsResult, ""),
"num_unconfirmed_txs": rpc.NewRPCFunc(NumUnconfirmedTxsResult, ""),
"unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"), "unsafe_set_config": rpc.NewRPCFunc(UnsafeSetConfigResult, "type,key,value"),
} }
@ -114,6 +115,14 @@ func UnconfirmedTxsResult() (ctypes.TMResult, error) {
} }
} }
func NumUnconfirmedTxsResult() (ctypes.TMResult, error) {
if r, err := NumUnconfirmedTxs(); err != nil {
return nil, err
} else {
return r, nil
}
}
func BroadcastTxSyncResult(tx []byte) (ctypes.TMResult, error) { func BroadcastTxSyncResult(tx []byte) (ctypes.TMResult, error) {
if r, err := BroadcastTxSync(tx); err != nil { if r, err := BroadcastTxSync(tx); err != nil {
return nil, err return nil, err


Loading…
Cancel
Save