From 2e7ff25b94006c4e0e6f2ecdc823c97b1c9df084 Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 14 Mar 2022 11:22:00 +1000 Subject: [PATCH] Implement ReadState Request::Transaction --- zebra-state/src/service.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zebra-state/src/service.rs b/zebra-state/src/service.rs index dd295064a87..9deb3c4ed15 100644 --- a/zebra-state/src/service.rs +++ b/zebra-state/src/service.rs @@ -937,7 +937,7 @@ impl Service for ReadStateService { } // For the get_raw_transaction RPC, to be implemented in #3145. - Request::Transaction(_hash) => { + Request::Transaction(hash) => { metrics::counter!( "state.requests", 1, @@ -945,7 +945,16 @@ impl Service for ReadStateService { "type" => "transaction", ); - unimplemented!("ReadStateService doesn't Transaction yet") + let state = self.clone(); + + async move { + let transaction = state.best_chain_receiver.with_watch_data(|best_chain| { + read::transaction(best_chain, &state.db, hash) + }); + + Ok(Response::Transaction(transaction)) + } + .boxed() } // TODO: split the Request enum, then implement these new ReadRequests for lightwalletd