mirror of
https://github.com/alexgo-io/bitcoin-indexer.git
synced 2026-01-12 16:52:57 +08:00
fix: transfer duplicates
This commit is contained in:
@@ -10,7 +10,7 @@ use chainhook_sdk::{
|
||||
use crate::{
|
||||
core::{compute_next_satpoint_data, SatPosition},
|
||||
db::{
|
||||
find_inscriptions_at_wached_outpoint, format_outpoint_to_watch,
|
||||
find_inscribed_ordinals_at_wached_outpoint, format_outpoint_to_watch,
|
||||
insert_transfer_in_locations_tx,
|
||||
},
|
||||
ord::height::Height,
|
||||
@@ -164,7 +164,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
|
||||
);
|
||||
|
||||
let entries =
|
||||
find_inscriptions_at_wached_outpoint(&outpoint_pre_transfer, &inscriptions_db_tx, ctx);
|
||||
find_inscribed_ordinals_at_wached_outpoint(&outpoint_pre_transfer, &inscriptions_db_tx, ctx);
|
||||
// For each satpoint inscribed retrieved, we need to compute the next
|
||||
// outpoint to watch
|
||||
for watched_satpoint in entries.into_iter() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
io::{Read, Write},
|
||||
path::PathBuf,
|
||||
thread::sleep,
|
||||
@@ -1168,27 +1168,32 @@ pub fn find_all_inscriptions_in_block(
|
||||
return results;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Ord, PartialOrd, PartialEq, Eq)]
|
||||
pub struct WatchedSatpoint {
|
||||
pub ordinal_number: u64,
|
||||
pub offset: u64,
|
||||
}
|
||||
|
||||
pub fn find_inscriptions_at_wached_outpoint(
|
||||
pub fn find_inscribed_ordinals_at_wached_outpoint(
|
||||
outpoint: &str,
|
||||
db_conn: &Connection,
|
||||
ctx: &Context,
|
||||
) -> Vec<WatchedSatpoint> {
|
||||
) -> BTreeSet<WatchedSatpoint> {
|
||||
let args: &[&dyn ToSql] = &[&outpoint.to_sql().unwrap()];
|
||||
let query = "SELECT ordinal_number, offset FROM locations WHERE outpoint_to_watch = ? ORDER BY offset ASC";
|
||||
perform_query_set(query, args, db_conn, ctx, |row| {
|
||||
let sat_points = perform_query_set(query, args, db_conn, ctx, |row| {
|
||||
let ordinal_number: u64 = row.get(0).unwrap();
|
||||
let offset: u64 = row.get(1).unwrap();
|
||||
WatchedSatpoint {
|
||||
ordinal_number,
|
||||
offset,
|
||||
}
|
||||
})
|
||||
});
|
||||
let mut res = BTreeSet::new();
|
||||
for sat_point in sat_points.into_iter() {
|
||||
res.insert(sat_point);
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
pub fn delete_inscriptions_in_block_range(
|
||||
|
||||
Reference in New Issue
Block a user