SHOWING: First 60
self.commit(wtx, value_cache)?;
value_cache = HashMap::new();
uncommitted = 0;
wtx = self.index.begin_write()?;
let height = wtx
.open_table(HEIGHT_TO_BLOCK_HASH)?
.range(0..)?
.next_back()
.and_then(|result| result.ok())
.map(|(height, _hash)| height.value() + 1)
.unwrap_or(0);
if height != self.height {
// another update has run between committing and beginning the new
// write transaction
break;
}
wtx
.open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)?
.insert(
&self.height,
&SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map(|duration| duration.as_millis())
.unwrap_or(0),
)?;
}
if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) {
break;
}
}
if uncommitted > 0 {
self.commit(wtx, value_cache)?;
}
#44,992,603text
if let Some(progress_bar) = &mut progress_bar {
progress_bar.finish_and_clear();
}
Ok(())
}
fn fetch_blocks_from(
index: &Index,
mut height: u32,
index_sats: bool,
) -> Result<mpsc::Receiver<BlockData>> {
let (tx, rx) = mpsc::sync_channel(32);
let height_limit = index.height_limit;
let client = index.options.bitcoin_rpc_client()?;
let first_inscription_height = index.first_inscription_height;
thread::spawn(move || loop {
if let Some(height_limit) = height_limit {
if height >= height_limit {
break;
}
}
match Self::get_block_with_retries(&client, height, index_sats, first_inscription_height) {
Ok(Some(block)) => {
if let Err(err) = tx.send(block.into()) {
log::info!("Block receiver disconnected: {err}");
break;
}
height += 1;
}
Ok(None) => break,
Err(err) => {
log::error!("failed to fetch block {height}: {err}");
#44,992,600text version: 1,
lock_time: LockTime::ZERO,
input: vec![tx_in(outpoint(1))],
output: vec![tx_out(3_333, change(1)), tx_out(6_537, recipient())],
})
)
}
#[test]
fn alignment_output_under_dust_limit_is_padded() {
let utxos = vec![
(outpoint(1), Amount::from_sat(10_000)),
(outpoint(2), Amount::from_sat(10_000)),
];
pretty_assert_eq!(
TransactionBuilder::new(
satpoint(1, 1),
BTreeMap::new(),
utxos.into_iter().collect(),
BTreeSet::new(),
recipient(),
[change(0), change(1)],
FeeRate::try_from(1.0).unwrap(),
Target::Postage,
)
.build_transaction(),
Ok(Transaction {
version: 1,
lock_time: LockTime::ZERO,
input: vec![tx_in(outpoint(2)), tx_in(outpoint(1))],
output: vec![tx_out(10_001, change(1)), tx_out(9_811, recipient())],
})
)
}
#[test]
#[should_panic(expected = "invariant: all outputs are either change or recipient")]
#44,992,597text
context.assert_runes(
[(
id,
RuneEntry {
etching: txid0,
rune: Rune(RUNE),
supply: u128::max_value(),
timestamp: 2,
..Default::default()
},
)],
[(OutPoint { txid, vout: 1 }, vec![(id, u128::max_value())])],
);
}
#[test]
fn rune_rarity_is_assigned_correctly() {
let context = Context::builder()
.arg("--index-runes-pre-alpha-i-agree-to-get-rekt")
.build();
context.mine_blocks(2);
let txid0 = context.rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, Witness::new())],
op_return: Some(
Runestone {
edicts: vec![Edict {
id: 0,
amount: u128::max_value(),
output: 0,
}],
etching: Some(Etching {
rune: Rune(RUNE),
..Default::default()
}),
..Default::default()
}
.encipher(),
),
..Default::default()
});
let id0 = RuneId {
#44,992,594texttransfer10,000.stst#40,911,034brc-20transfer1,000.bear#39,610,928brc-20transfer2,000.bear#39,606,344brc-20transfer3,000.bear#39,382,948brc-20transfer2,000.bear#39,326,373brc-20transfer2,000.bear#39,146,866brc-20mint1.3165#38,946,126brc-20deploy.3165#38,944,158brc-20transfer50,000,000,000.sats#38,680,449brc-20transfer10.btcs#35,323,103brc-20transfer100,000,000,000.sats#33,349,424brc-20transfer20,000,000,000.sats#33,249,941brc-20transfer22,000,000,000.sats#32,684,344brc-20transfer2,000,000,000.sats#22,219,385brc-20transfer1,000,000,000.sats#19,860,764brc-20############################################################
{"p":"gen-brc-721","op":"mint","s":"ordibotmrs","t_ins":["fd0d94695fc30af6238732c2b71aa4330511c5d2dd0ace2da05660c2ad57076di0"],"h":"c3455c581b484899730f00b75ed085f0e10838bb49b6acc546d42947893e7c1c","id":"635","a":[[0,"purple"],[0,"none"],[0,"ponytail-white"],[0,"ushape"],[0,"unimpressed"]]}
#############################################################9,957,840textmint#9,955,896gen-brc-721#############################################################9,955,895text#############################################################9,955,894text#############################################################9,955,893text#############################################################9,955,892text#############################################################9,955,891textmint#9,955,890gen-brc-721mint#9,955,889gen-brc-721mint#9,955,888gen-brc-721#############################################################9,955,887texttransfer30,240.cula#5,626,872brc-20mint1,260.cula#5,553,524brc-20mint1,260.cula#5,553,500brc-20mint1,260.cula#5,553,445brc-20mint1,260.cula#5,553,357brc-20mint1,260.cula#5,553,282brc-20mint1,260.cula#5,553,270brc-20mint1,260.cula#5,553,219brc-20mint1,260.cula#5,553,214brc-20mint1,260.cula#5,553,196brc-20mint1,260.cula#5,553,123brc-20mint1,260.cula#5,553,033brc-20mint1,260.cula#5,553,023brc-20mint1,260.cula#5,553,022brc-20mint1,260.cula#5,552,966brc-20