Skip to content

Commit 3e7a1be

Browse files
committed
updated vin and vout table as Txid
1 parent a06293d commit 3e7a1be

5 files changed

Lines changed: 8 additions & 14 deletions

File tree

lib/ain-ocean/src/indexer/transaction.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bitcoin::{blockdata::locktime::absolute::LockTime, Txid};
2-
use dftx_rs::Transaction;
2+
use dftx_rs::{Block, Transaction};
33
use log::debug;
44

55
use super::BlockContext;
@@ -42,7 +42,7 @@ pub fn index_transactions(ctx: &BlockContext, tx: Transaction) -> Result<()> {
4242
};
4343
// Index transaction
4444
SERVICES.transaction.by_id.put(&tx_id, &trx)?;
45-
// Index transaction vin
45+
// Indexing transaction vin
4646
for (vin_idx, vin) in tx.input.iter().enumerate() {
4747
let trx_vin = TransactionVin {
4848
id: format!("{}-{}", tx_id, vin_idx),
@@ -65,10 +65,7 @@ pub fn index_transactions(ctx: &BlockContext, tx: Transaction) -> Result<()> {
6565
sequence: vin.sequence.to_string(),
6666
};
6767

68-
SERVICES
69-
.transaction
70-
.vin_by_id
71-
.put(&tx_id.to_string(), &trx_vin)?;
68+
SERVICES.transaction.vin_by_id.put(&tx_id, &trx_vin)?;
7269
}
7370
// Index transaction vout
7471
for (vout_idx, vout) in tx.output.iter().enumerate() {
@@ -83,10 +80,7 @@ pub fn index_transactions(ctx: &BlockContext, tx: Transaction) -> Result<()> {
8380
r#type: "pubkey".to_string(),
8481
},
8582
};
86-
SERVICES
87-
.transaction
88-
.vout_by_id
89-
.put(&tx_id.to_string(), &trx_vout)?;
83+
SERVICES.transaction.vout_by_id.put(&tx_id, &trx_vout)?;
9084
// .put(&format!("{}-{}", tx_id, vout_idx), &trx_vout)?; //need
9185
}
9286

lib/ain-ocean/src/repository/transaction_vin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
};
1313

1414
#[derive(Repository)]
15-
#[repository(K = "String", V = "TransactionVin")]
15+
#[repository(K = "Txid", V = "TransactionVin")]
1616
pub struct TransactionVinRepository {
1717
pub store: Arc<OceanStore>,
1818
col: LedgerColumn<columns::TransactionVin>,

lib/ain-ocean/src/repository/transaction_vout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
};
1313

1414
#[derive(Repository)]
15-
#[repository(K = "String", V = "TransactionVout")]
15+
#[repository(K = "Txid", V = "TransactionVout")]
1616
pub struct TransactionVoutRepository {
1717
pub store: Arc<OceanStore>,
1818
col: LedgerColumn<columns::TransactionVout>,

lib/ain-ocean/src/storage/columns/transaction_vin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl ColumnName for TransactionVin {
1111
}
1212

1313
impl Column for TransactionVin {
14-
type Index = String;
14+
type Index = Txid;
1515
}
1616

1717
impl TypedColumn for TransactionVin {

lib/ain-ocean/src/storage/columns/transaction_vout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl ColumnName for TransactionVout {
1010
}
1111

1212
impl Column for TransactionVout {
13-
type Index = String;
13+
type Index = Txid;
1414
}
1515

1616
impl TypedColumn for TransactionVout {

0 commit comments

Comments
 (0)