@@ -5,7 +5,7 @@ use std::{
5
5
6
6
use bitcoin:: ScriptBuf ;
7
7
use chainhook_sdk:: utils:: Context ;
8
- use ordinals:: { Cenotaph , Edict , Etching , Rune , RuneId , Runestone } ;
8
+ use ordinals:: { Cenotaph , Edict , Etching , Rune , RuneId } ;
9
9
10
10
use crate :: {
11
11
db:: {
@@ -30,20 +30,20 @@ pub struct InputRuneBalance {
30
30
/// Holds cached data relevant to a single transaction during indexing.
31
31
pub struct TransactionCache {
32
32
pub location : TransactionLocation ,
33
- /// Index of the ledger entry we're inserting next for this transaction.
33
+ /// Sequential index of the ledger entry we're inserting next for this transaction. Will be increased with each generated
34
+ /// entry.
34
35
next_event_index : u32 ,
35
- /// Rune etched during this transaction
36
+ /// Rune etched during this transaction, if any.
36
37
pub etching : Option < DbRune > ,
37
- /// The output where all unallocated runes will be transferred to.
38
- pointer : Option < u32 > ,
38
+ /// The output where all unallocated runes will be transferred to. Set to the first eligible output by default but can be
39
+ /// overridden by a Runestone.
40
+ pub output_pointer : Option < u32 > ,
39
41
/// Holds input runes for the current transaction (input to this tx, premined or minted). Balances in the vector are in the
40
42
/// order in which they were input to this transaction.
41
43
input_runes : HashMap < RuneId , VecDeque < InputRuneBalance > > ,
42
44
/// Non-OP_RETURN outputs in this transaction
43
45
eligible_outputs : HashMap < u32 , ScriptBuf > ,
44
- /// Index of the output that should receive unallocated runes if there is no `pointer` present.
45
- first_eligible_output : Option < u32 > ,
46
- /// Total outputs contained in this transaction, including OP_RETURN outputs
46
+ /// Total outputs contained in this transaction, including non-eligible outputs.
47
47
total_outputs : u32 ,
48
48
}
49
49
@@ -59,25 +59,13 @@ impl TransactionCache {
59
59
location,
60
60
next_event_index : 0 ,
61
61
etching : None ,
62
- pointer : None ,
62
+ output_pointer : first_eligible_output ,
63
63
input_runes,
64
64
eligible_outputs,
65
- first_eligible_output,
66
65
total_outputs,
67
66
}
68
67
}
69
68
70
- /// Takes the runestone's output pointer and keeps a record of eligible outputs to send runes to.
71
- pub fn apply_runestone_pointer ( & mut self , runestone : & Runestone , _ctx : & Context ) {
72
- self . pointer = if runestone. pointer . is_some ( ) {
73
- runestone. pointer
74
- } else if self . first_eligible_output . is_some ( ) {
75
- self . first_eligible_output
76
- } else {
77
- None
78
- } ;
79
- }
80
-
81
69
/// Burns the rune balances input to this transaction.
82
70
pub fn apply_cenotaph_input_burn ( & mut self , _cenotaph : & Cenotaph ) -> Vec < DbLedgerEntry > {
83
71
let mut results = vec ! [ ] ;
@@ -104,20 +92,21 @@ impl TransactionCache {
104
92
pub fn allocate_remaining_balances ( & mut self , ctx : & Context ) -> Vec < DbLedgerEntry > {
105
93
let mut results = vec ! [ ] ;
106
94
for ( rune_id, unallocated) in self . input_runes . iter_mut ( ) {
107
- #[ cfg( feature = "debug" ) ]
95
+ #[ cfg( not ( feature = "release" ) ) ]
108
96
for input in unallocated. iter ( ) {
109
97
try_debug ! (
110
98
ctx,
111
- "Assign unallocated {} {:?} ({}) {}" ,
99
+ "Assign unallocated {} to pointer {:?} {:?} ({}) {}" ,
112
100
rune_id,
101
+ self . output_pointer,
113
102
input. address,
114
103
input. amount,
115
104
self . location
116
105
) ;
117
106
}
118
107
results. extend ( move_rune_balance_to_output (
119
108
& self . location ,
120
- self . pointer ,
109
+ self . output_pointer ,
121
110
rune_id,
122
111
unallocated,
123
112
& self . eligible_outputs ,
0 commit comments