@@ -17,6 +17,7 @@ use std::{
17
17
} ;
18
18
19
19
use indexmap:: { IndexMap , IndexSet } ;
20
+ use monero_serai:: block:: Block ;
20
21
use rayon:: {
21
22
iter:: { Either , IntoParallelIterator , ParallelIterator } ,
22
23
prelude:: * ,
@@ -54,8 +55,8 @@ use crate::{
54
55
types:: { BlockchainReadHandle , ResponseResult } ,
55
56
} ,
56
57
tables:: {
57
- AltBlockHeights , BlockHeights , BlockInfos , OpenTables , RctOutputs , Tables , TablesIter ,
58
- TxIds , TxOutputs ,
58
+ AltBlockHeights , BlockHeaderBlobs , BlockHeights , BlockInfos , OpenTables , RctOutputs ,
59
+ Tables , TablesIter , TxIds , TxOutputs ,
59
60
} ,
60
61
types:: {
61
62
AltBlockHeight , Amount , AmountIndex , BlockHash , BlockHeight , KeyImage , PreRctOutputId ,
@@ -888,11 +889,31 @@ fn alt_blocks_in_chain(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult {
888
889
889
890
/// [`BlockchainReadRequest::Block`]
890
891
fn block ( env : & ConcreteEnv , block_height : BlockHeight ) -> ResponseResult {
891
- Ok ( BlockchainResponse :: Block ( todo ! ( ) ) )
892
+ // Single-threaded, no `ThreadLocal` required.
893
+ let env_inner = env. env_inner ( ) ;
894
+ let tx_ro = env_inner. tx_ro ( ) ?;
895
+
896
+ let block_blob = env_inner
897
+ . open_db_ro :: < BlockHeaderBlobs > ( & tx_ro) ?
898
+ . get ( & block_height) ?;
899
+
900
+ let block = Block :: read ( & mut block_blob. 0 . as_slice ( ) ) ?;
901
+
902
+ Ok ( BlockchainResponse :: Block ( block) )
892
903
}
893
904
894
905
/// [`BlockchainReadRequest::BlockByHash`]
895
906
fn block_by_hash ( env : & ConcreteEnv , block_hash : BlockHash ) -> ResponseResult {
907
+ // Single-threaded, no `ThreadLocal` required.
908
+ let env_inner = env. env_inner ( ) ;
909
+ let tx_ro = env_inner. tx_ro ( ) ?;
910
+
911
+ let tables = env_inner. open_tables ( & tx_ro) ?;
912
+ let block_height = tables. block_heights ( ) . get ( & block_hash) ?;
913
+ let block_blob = tables. block_header_blobs ( ) . get ( & block_height) ?;
914
+
915
+ let block = Block :: read ( & mut block_blob. 0 . as_slice ( ) ) ?;
916
+
896
917
Ok ( BlockchainResponse :: Block ( todo ! ( ) ) )
897
918
}
898
919
0 commit comments