Skip to content

Commit b264e72

Browse files
author
Ludo Galabru
committed
feat: draft ordhook-sdk-js
1 parent 4f5cb49 commit b264e72

File tree

18 files changed

+8618
-21
lines changed

18 files changed

+8618
-21
lines changed

Cargo.lock

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"components/ordhook-cli",
44
"components/ordhook-core",
5+
"components/ordhook-sdk-js"
56
]
67

78
default-members = ["components/ordhook-cli"]

components/ordhook-core/src/core/pipeline/processors/inscription_indexing.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use crate::{
2121
core::{
2222
pipeline::processors::block_archiving::store_compacted_blocks,
2323
protocol::{
24-
inscription_parsing::{get_inscriptions_revealed_in_block, get_inscriptions_transferred_in_block},
24+
inscription_parsing::{
25+
get_inscriptions_revealed_in_block, get_inscriptions_transferred_in_block,
26+
},
2527
inscription_sequencing::{
2628
augment_block_with_ordinals_inscriptions_data_and_write_to_db_tx,
2729
parallelize_inscription_data_computations, SequenceCursor,

components/ordhook-core/src/core/protocol/inscription_parsing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use chainhook_sdk::bitcoincore_rpc_json::bitcoin::Txid;
66
use chainhook_sdk::indexer::bitcoin::{standardize_bitcoin_block, BitcoinBlockFullBreakdown};
77
use chainhook_sdk::types::{
88
BitcoinBlockData, BitcoinNetwork, BitcoinTransactionData, OrdinalInscriptionCurseType,
9-
OrdinalInscriptionRevealData, OrdinalOperation, OrdinalInscriptionTransferData,
9+
OrdinalInscriptionRevealData, OrdinalInscriptionTransferData, OrdinalOperation,
1010
};
1111
use chainhook_sdk::utils::Context;
1212
use chainhook_sdk::{

components/ordhook-core/src/scan/bitcoin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use chainhook_sdk::chainhooks::types::BitcoinChainhookSpecification;
1919
use chainhook_sdk::indexer::bitcoin::{
2020
build_http_client, download_and_parse_block_with_retry, retrieve_block_hash_with_retry,
2121
};
22-
use chainhook_sdk::observer::{gather_proofs, EventObserverConfig};
22+
use chainhook_sdk::observer::{gather_proofs, DataHandlerEvent, EventObserverConfig};
2323
use chainhook_sdk::types::{
2424
BitcoinBlockData, BitcoinChainEvent, BitcoinChainUpdatedWithBlocksData,
2525
};
@@ -273,7 +273,7 @@ pub async fn execute_predicates_action<'a>(
273273
}
274274
BitcoinChainhookOccurrence::Data(payload) => {
275275
if let Some(ref tx) = config.data_handler_tx {
276-
let _ = tx.send(payload);
276+
let _ = tx.send(DataHandlerEvent::Process(payload));
277277
}
278278
}
279279
};

components/ordhook-core/src/service/mod.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use chainhook_sdk::chainhooks::types::{
3131
BitcoinChainhookSpecification, ChainhookFullSpecification, ChainhookSpecification,
3232
};
3333
use chainhook_sdk::observer::{
34-
start_event_observer, BitcoinBlockDataCached, EventObserverConfig, HandleBlock,
35-
ObserverCommand, ObserverEvent, ObserverSidecar,
34+
start_event_observer, BitcoinBlockDataCached, DataHandlerEvent, EventObserverConfig,
35+
HandleBlock, ObserverCommand, ObserverEvent, ObserverSidecar,
3636
};
3737
use chainhook_sdk::types::{BitcoinBlockData, BlockIdentifier};
3838
use chainhook_sdk::utils::{BlockHeights, Context};
@@ -374,7 +374,7 @@ impl Service {
374374
) -> Result<
375375
(
376376
EventObserverConfig,
377-
Option<crossbeam_channel::Receiver<BitcoinChainhookOccurrencePayload>>,
377+
Option<crossbeam_channel::Receiver<DataHandlerEvent>>,
378378
),
379379
String,
380380
> {
@@ -456,9 +456,7 @@ impl Service {
456456
&self.ctx,
457457
)?;
458458
}
459-
460459
let tx_replayer = start_observer_forwarding(event_observer_config, &self.ctx);
461-
462460
self.update_state(Some(tx_replayer)).await?;
463461
Ok(())
464462
}
@@ -469,7 +467,6 @@ impl Service {
469467
) -> Result<(), String> {
470468
// Start predicate processor
471469
let mut last_block_processed = 0;
472-
473470
while let Some((start_block, end_block, speed)) =
474471
should_sync_ordhook_db(&self.config, &self.ctx)?
475472
{
@@ -482,10 +479,12 @@ impl Service {
482479
block_post_processor.clone(),
483480
);
484481

485-
info!(
486-
self.ctx.expect_logger(),
487-
"Indexing inscriptions from block #{start_block} to block #{end_block}"
488-
);
482+
self.ctx.try_log(|logger| {
483+
info!(
484+
logger,
485+
"Indexing inscriptions from block #{start_block} to block #{end_block}"
486+
)
487+
});
489488

490489
let ordhook_config = self.config.get_ordhook_config();
491490
let first_inscription_height = ordhook_config.first_inscription_height;
@@ -515,7 +514,7 @@ impl Service {
515514
let blocks_post_processor =
516515
start_transfers_recomputing_processor(&self.config, &self.ctx, block_post_processor);
517516

518-
let ordhook_config = self.config.get_ordhook_config();
517+
let ordhook_config = self.config.get_ordhook_config();
519518
let first_inscription_height = ordhook_config.first_inscription_height;
520519
download_and_pipeline_blocks(
521520
&self.config,

0 commit comments

Comments
 (0)