mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
computer: stateful: reset when reorg detected
This commit is contained in:
@@ -1289,7 +1289,7 @@ impl Vecs {
|
|||||||
base_version + self.height_to_opreturn_supply.inner_version(),
|
base_version + self.height_to_opreturn_supply.inner_version(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut chain_state: Vec<BlockState>;
|
let mut chain_state: Vec<BlockState> = vec![];
|
||||||
let mut chain_state_starting_height = Height::from(self.chain_state.len());
|
let mut chain_state_starting_height = Height::from(self.chain_state.len());
|
||||||
|
|
||||||
let stateful_starting_height = match separate_utxo_vecs
|
let stateful_starting_height = match separate_utxo_vecs
|
||||||
@@ -1322,25 +1322,27 @@ impl Vecs {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
chain_state_starting_height
|
chain_state_starting_height
|
||||||
}
|
}
|
||||||
Ordering::Less => {
|
Ordering::Less => Height::ZERO,
|
||||||
// todo!("rollback instead");
|
|
||||||
chain_state = vec![];
|
|
||||||
chain_state_starting_height = Height::ZERO;
|
|
||||||
Height::ZERO
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if stateful_starting_height.is_zero() {
|
|
||||||
info!("Starting processing utxos from the start");
|
|
||||||
separate_utxo_vecs
|
|
||||||
.par_iter_mut()
|
|
||||||
.try_for_each(|(_, v)| v.state.price_to_amount.reset())?;
|
|
||||||
}
|
|
||||||
let starting_height = starting_indexes
|
let starting_height = starting_indexes
|
||||||
.height
|
.height
|
||||||
.min(stateful_starting_height)
|
.min(stateful_starting_height)
|
||||||
.min(Height::from(self.height_to_unspendable_supply.len()))
|
.min(Height::from(self.height_to_unspendable_supply.len()))
|
||||||
.min(Height::from(self.height_to_opreturn_supply.len()));
|
.min(Height::from(self.height_to_opreturn_supply.len()));
|
||||||
|
|
||||||
|
if starting_height.is_zero() {
|
||||||
|
info!("Starting processing utxos from the start");
|
||||||
|
|
||||||
|
// todo!("rollback instead");
|
||||||
|
chain_state = vec![];
|
||||||
|
chain_state_starting_height = Height::ZERO;
|
||||||
|
|
||||||
|
separate_utxo_vecs
|
||||||
|
.par_iter_mut()
|
||||||
|
.try_for_each(|(_, v)| v.state.price_to_amount.reset())?;
|
||||||
|
}
|
||||||
|
|
||||||
if starting_height == Height::from(height_to_date_fixed.len()) {
|
if starting_height == Height::from(height_to_date_fixed.len()) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
|
|
||||||
Binance::fetch_1d().map(|b| {
|
Binance::fetch_1d().map(|b| {
|
||||||
dbg!(b.last_key_value());
|
dbg!(b.last_key_value());
|
||||||
});
|
})?;
|
||||||
Kraken::fetch_1d().map(|b| {
|
Kraken::fetch_1d().map(|b| {
|
||||||
dbg!(b.last_key_value());
|
dbg!(b.last_key_value());
|
||||||
});
|
})?;
|
||||||
Binance::fetch_1mn().map(|b| {
|
Binance::fetch_1mn().map(|b| {
|
||||||
dbg!(b.last_key_value());
|
dbg!(b.last_key_value());
|
||||||
});
|
})?;
|
||||||
Kraken::fetch_1mn().map(|b| {
|
Kraken::fetch_1mn().map(|b| {
|
||||||
dbg!(b.last_key_value());
|
dbg!(b.last_key_value());
|
||||||
});
|
})?;
|
||||||
|
|
||||||
dbg!(fetcher.get_date(Date::new(2025, 6, 5))?);
|
dbg!(fetcher.get_date(Date::new(2025, 6, 5))?);
|
||||||
dbg!(fetcher.get_height(
|
dbg!(fetcher.get_height(
|
||||||
|
|||||||
@@ -110,13 +110,7 @@ impl TryFrom<(&mut Vecs, &Stores, &Client)> for Indexes {
|
|||||||
vecs.height_to_blockhash
|
vecs.height_to_blockhash
|
||||||
.iter()
|
.iter()
|
||||||
.get(*height)
|
.get(*height)
|
||||||
.is_none_or(|saved_blockhash| {
|
.is_none_or(|saved_blockhash| &rpc_blockhash != saved_blockhash.as_ref())
|
||||||
let b = &rpc_blockhash != saved_blockhash.as_ref();
|
|
||||||
if b {
|
|
||||||
dbg!(rpc_blockhash, saved_blockhash.as_ref());
|
|
||||||
}
|
|
||||||
b
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.unwrap_or(starting_height);
|
.unwrap_or(starting_height);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kibo.money",
|
"name": "brk",
|
||||||
"short_name": "kibo",
|
"short_name": "brk",
|
||||||
"description": "A better, FOSS, Bitcoin-only, self-hostable Glassnode",
|
"description": "A better, FOSS, Bitcoin-only, self-hostable Glassnode",
|
||||||
"categories": [
|
"categories": [
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// File auto-generated, any modifications will be overwritten
|
// File auto-generated, any modifications will be overwritten
|
||||||
//
|
//
|
||||||
|
|
||||||
export const VERSION = "v0.0.54";
|
export const VERSION = "v0.0.55";
|
||||||
|
|
||||||
/** @typedef {0} DateIndex */
|
/** @typedef {0} DateIndex */
|
||||||
/** @typedef {1} DecadeIndex */
|
/** @typedef {1} DecadeIndex */
|
||||||
|
|||||||
Reference in New Issue
Block a user