From 115e57a1d528d5e48ba1fcecfd13d4fd754619fd Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sat, 25 Apr 2015 13:26:36 -0700 Subject: [PATCH] list_unconfirmed_txs RPC call --- rpc/core/mempool.go | 7 ++++--- rpc/core/routes.go | 1 + rpc/core/types/responses.go | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 6d5d9892..4fa93560 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -30,6 +30,7 @@ func BroadcastTx(tx types.Tx) (*ctypes.ResponseBroadcastTx, error) { return &ctypes.ResponseBroadcastTx{ctypes.Receipt{txHash, createsContract, contractAddr}}, nil } -/* -curl -H 'content-type: text/plain;' http://127.0.0.1:8888/submit_tx?tx=... -*/ +func ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) { + txs := mempoolReactor.Mempool.GetProposalTxs() + return &ctypes.ResponseListUnconfirmedTxs{txs}, nil +} diff --git a/rpc/core/routes.go b/rpc/core/routes.go index 17f196ab..6ba49c49 100644 --- a/rpc/core/routes.go +++ b/rpc/core/routes.go @@ -17,6 +17,7 @@ var Routes = map[string]*rpc.RPCFunc{ "dump_consensus_state": rpc.NewRPCFunc(DumpConsensusState, []string{}), "dump_storage": rpc.NewRPCFunc(DumpStorage, []string{"address"}), "broadcast_tx": rpc.NewRPCFunc(BroadcastTx, []string{"tx"}), + "list_unconfirmed_txs": rpc.NewRPCFunc(ListUnconfirmedTxs, []string{}), "list_accounts": rpc.NewRPCFunc(ListAccounts, []string{}), "unsafe/gen_priv_account": rpc.NewRPCFunc(GenPrivAccount, []string{}), "unsafe/sign_tx": rpc.NewRPCFunc(SignTx, []string{"tx", "privAccounts"}), diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 79d42e03..0f3cdd49 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -50,11 +50,14 @@ type ResponseGetBlock struct { Block *types.Block } -// curl -H 'content-type: text/plain;' http://127.0.0.1:8888/submit_tx?tx=... type ResponseBroadcastTx struct { Receipt Receipt } +type ResponseListUnconfirmedTxs struct { + Txs []types.Tx +} + type Receipt struct { TxHash []byte CreatesContract uint8