@@ -32,6 +32,7 @@ use ordhook::db::{
32
32
use ordhook:: download:: download_ordinals_dataset_if_required;
33
33
use ordhook:: hex;
34
34
use ordhook:: scan:: bitcoin:: scan_bitcoin_chainstate_via_rpc_using_predicate;
35
+ use ordhook:: service:: observers:: initialize_observers_db;
35
36
use ordhook:: service:: { start_observer_forwarding, Service } ;
36
37
use reqwest:: Client as HttpClient ;
37
38
use std:: io:: { BufReader , Read } ;
@@ -163,6 +164,8 @@ struct ScanTransactionCommand {
163
164
pub block_height : u64 ,
164
165
/// Inscription Id
165
166
pub transaction_id : String ,
167
+ /// Input index
168
+ pub input_index : usize ,
166
169
/// Target Regtest network
167
170
#[ clap(
168
171
long = "regtest" ,
@@ -558,6 +561,9 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
558
561
None ,
559
562
cmd. auth_token ,
560
563
) ?;
564
+
565
+ let _ = initialize_observers_db ( & config. expected_cache_path ( ) , ctx) ;
566
+
561
567
scan_bitcoin_chainstate_via_rpc_using_predicate (
562
568
& predicate_spec,
563
569
& config,
@@ -575,15 +581,14 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
575
581
while let Some ( block_height) = block_range. pop_front ( ) {
576
582
let inscriptions =
577
583
find_all_inscriptions_in_block ( & block_height, & inscriptions_db_conn, ctx) ;
578
- let mut locations =
584
+ let locations =
579
585
find_all_transfers_in_block ( & block_height, & inscriptions_db_conn, ctx) ;
580
586
581
587
let mut total_transfers_in_block = 0 ;
582
588
583
589
for ( _, inscription) in inscriptions. iter ( ) {
584
590
println ! ( "Inscription {} revealed at block #{} (inscription_number {}, ordinal_number {})" , inscription. get_inscription_id( ) , block_height, inscription. inscription_number. jubilee, inscription. ordinal_number) ;
585
- if let Some ( transfers) = locations. remove ( & inscription. get_inscription_id ( ) )
586
- {
591
+ if let Some ( transfers) = locations. get ( & inscription. ordinal_number ) {
587
592
for t in transfers. iter ( ) . skip ( 1 ) {
588
593
total_transfers_in_block += 1 ;
589
594
println ! (
@@ -672,18 +677,21 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
672
677
. await ?;
673
678
let transaction_identifier = TransactionIdentifier :: new ( & cmd. transaction_id ) ;
674
679
let cache = new_traversals_lazy_cache ( 100 ) ;
675
- let ( res, mut back_trace) = compute_satoshi_number (
680
+ let ( res, _ , mut back_trace) = compute_satoshi_number (
676
681
& config. get_ordhook_config ( ) . db_path ,
677
682
& block. block_identifier ,
678
683
& transaction_identifier,
684
+ cmd. input_index ,
679
685
0 ,
680
686
& Arc :: new ( cache) ,
687
+ config. resources . ulimit ,
688
+ config. resources . memory_available ,
681
689
true ,
682
690
ctx,
683
691
) ?;
684
692
back_trace. reverse ( ) ;
685
- for ( block_height, tx) in back_trace. iter ( ) {
686
- println ! ( "{}\t {}" , block_height, hex:: encode( tx) ) ;
693
+ for ( block_height, tx, index ) in back_trace. iter ( ) {
694
+ println ! ( "{}\t {}:{} " , block_height, hex:: encode( tx) , index ) ;
687
695
}
688
696
println ! ( "{:?}" , res) ;
689
697
}
@@ -707,7 +715,13 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
707
715
let last_known_block =
708
716
find_latest_inscription_block_height ( & inscriptions_db_conn, ctx) ?;
709
717
if last_known_block. is_none ( ) {
710
- open_ordhook_db_conn_rocks_db_loop ( true , & config. expected_cache_path ( ) , ctx) ;
718
+ open_ordhook_db_conn_rocks_db_loop (
719
+ true ,
720
+ & config. expected_cache_path ( ) ,
721
+ config. resources . ulimit ,
722
+ config. resources . memory_available ,
723
+ ctx,
724
+ ) ;
711
725
}
712
726
713
727
let ordhook_config = config. get_ordhook_config ( ) ;
@@ -766,7 +780,13 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
766
780
Command :: Db ( OrdhookDbCommand :: New ( cmd) ) => {
767
781
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
768
782
initialize_ordhook_db ( & config. expected_cache_path ( ) , ctx) ;
769
- open_ordhook_db_conn_rocks_db_loop ( true , & config. expected_cache_path ( ) , ctx) ;
783
+ open_ordhook_db_conn_rocks_db_loop (
784
+ true ,
785
+ & config. expected_cache_path ( ) ,
786
+ config. resources . ulimit ,
787
+ config. resources . memory_available ,
788
+ ctx,
789
+ ) ;
770
790
}
771
791
Command :: Db ( OrdhookDbCommand :: Sync ( cmd) ) => {
772
792
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
@@ -779,10 +799,7 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
779
799
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
780
800
let mut ordhook_config = config. get_ordhook_config ( ) ;
781
801
if let Some ( network_threads) = cmd. network_threads {
782
- ordhook_config. network_thread_max = network_threads;
783
- }
784
- if let Some ( network_threads) = cmd. network_threads {
785
- ordhook_config. network_thread_max = network_threads;
802
+ ordhook_config. resources . bitcoind_rpc_threads = network_threads;
786
803
}
787
804
let blocks = cmd. get_blocks ( ) ;
788
805
let block_ingestion_processor =
@@ -800,6 +817,8 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
800
817
let blocks_db = open_ordhook_db_conn_rocks_db_loop (
801
818
false ,
802
819
& config. get_ordhook_config ( ) . db_path ,
820
+ config. resources . ulimit ,
821
+ config. resources . memory_available ,
803
822
ctx,
804
823
) ;
805
824
for i in cmd. get_blocks ( ) . into_iter ( ) {
@@ -819,7 +838,7 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
819
838
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
820
839
let mut ordhook_config = config. get_ordhook_config ( ) ;
821
840
if let Some ( network_threads) = cmd. network_threads {
822
- ordhook_config. network_thread_max = network_threads;
841
+ ordhook_config. resources . bitcoind_rpc_threads = network_threads;
823
842
}
824
843
let block_post_processor = match cmd. repair_observers {
825
844
Some ( true ) => {
@@ -870,8 +889,12 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
870
889
Command :: Db ( OrdhookDbCommand :: Check ( cmd) ) => {
871
890
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
872
891
{
873
- let blocks_db =
874
- open_readonly_ordhook_db_conn_rocks_db ( & config. expected_cache_path ( ) , ctx) ?;
892
+ let blocks_db = open_readonly_ordhook_db_conn_rocks_db (
893
+ & config. expected_cache_path ( ) ,
894
+ config. resources . ulimit ,
895
+ config. resources . memory_available ,
896
+ ctx,
897
+ ) ?;
875
898
let tip = find_last_block_inserted ( & blocks_db) ;
876
899
println ! ( "Tip: {}" , tip) ;
877
900
let missing_blocks = find_missing_blocks ( & blocks_db, 1 , tip, ctx) ;
@@ -880,8 +903,13 @@ async fn handle_command(opts: Opts, ctx: &Context) -> Result<(), String> {
880
903
}
881
904
Command :: Db ( OrdhookDbCommand :: Drop ( cmd) ) => {
882
905
let config = ConfigFile :: default ( false , false , false , & cmd. config_path ) ?;
883
- let blocks_db =
884
- open_ordhook_db_conn_rocks_db_loop ( true , & config. expected_cache_path ( ) , ctx) ;
906
+ let blocks_db = open_ordhook_db_conn_rocks_db_loop (
907
+ true ,
908
+ & config. expected_cache_path ( ) ,
909
+ config. resources . ulimit ,
910
+ config. resources . memory_available ,
911
+ ctx,
912
+ ) ;
885
913
let inscriptions_db_conn_rw =
886
914
open_readwrite_ordhook_db_conn ( & config. expected_cache_path ( ) , ctx) ?;
887
915
0 commit comments