Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/floresta-chain/src/pruned_utreexo/chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ impl<PersistedState: ChainStore> BlockchainInterface for ChainState<PersistedSta
Ok(hashes)
}

fn is_in_idb(&self) -> bool {
fn is_in_ibd(&self) -> bool {
self.inner.read().ibd
}

Expand Down Expand Up @@ -1140,7 +1140,7 @@ impl<PersistedState: ChainStore> UpdatableChainstate for ChainState<PersistedSta
#[cfg(feature = "metrics")]
metrics::get_metrics().block_height.set(height.into());

if !self.is_in_idb() || height % 10_000 == 0 {
if !self.is_in_ibd() || height % 10_000 == 0 {
self.flush()?;
}

Expand Down
10 changes: 5 additions & 5 deletions crates/floresta-chain/src/pruned_utreexo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub trait BlockchainInterface {
/// vector or a channel where data can be transferred to the atual worker, otherwise
/// chainstate will be stuck for as long as you have work to do.
fn subscribe(&self, tx: Arc<dyn BlockConsumer>);
/// Tells whether or not we are on ibd
fn is_in_idb(&self) -> bool;
/// Tells whether or not we are on IBD
fn is_in_ibd(&self) -> bool;
/// Returns the list of unbroadcasted transactions.
fn get_unbroadcasted(&self) -> Vec<Transaction>;
/// Checks if a coinbase is mature
Expand Down Expand Up @@ -134,7 +134,7 @@ pub trait UpdatableChainstate {
fn handle_transaction(&self) -> Result<(), BlockchainError>;
/// Persists our data. Should be invoked periodically.
fn flush(&self) -> Result<(), BlockchainError>;
/// Toggle ibd on/off
/// Toggle IBD on/off
fn toggle_ibd(&self, is_ibd: bool);
/// Tells this blockchain to consider this block invalid, and not build on top of it
fn invalidate_block(&self, block: BlockHash) -> Result<(), BlockchainError>;
Expand Down Expand Up @@ -295,8 +295,8 @@ impl<T: BlockchainInterface> BlockchainInterface for Arc<T> {
T::subscribe(self, tx)
}

fn is_in_idb(&self) -> bool {
T::is_in_idb(self)
fn is_in_ibd(&self) -> bool {
T::is_in_ibd(self)
}

fn get_height(&self) -> Result<u32, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion crates/floresta-chain/src/pruned_utreexo/partial_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ impl BlockchainInterface for PartialChainState {
Ok(self.inner().current_height)
}

fn is_in_idb(&self) -> bool {
fn is_in_ibd(&self) -> bool {
!self.inner().is_sync()
}

Expand Down
4 changes: 2 additions & 2 deletions crates/floresta-electrum/src/electrum_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl<Blockchain: BlockchainInterface> ElectrumServer<Blockchain> {

// rescan for new addresses, if any
if !self.addresses_to_scan.is_empty() {
if self.chain.is_in_idb() {
if self.chain.is_in_ibd() {
continue;
}

Expand Down Expand Up @@ -647,7 +647,7 @@ impl<Blockchain: BlockchainInterface> ElectrumServer<Blockchain> {

let current_height = self.address_cache.get_cache_height();

if (!self.chain.is_in_idb() || height % 1000 == 0) && (height > current_height) {
if (!self.chain.is_in_ibd() || height % 1000 == 0) && (height > current_height) {
self.address_cache.bump_height(height);
}

Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-wire/src/cli_wire/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl UtreexodBackend {
// We don't download genesis, because utreexod will error out if we try to fetch
// proof for it.
let current = if current == 0 { 1 } else { current };
if self.chainstate.is_in_idb() {
if self.chainstate.is_in_ibd() {
info!("Start Initial Block Download at height {current} of {height}");
}
for block_height in current..=height {
Expand All @@ -172,7 +172,7 @@ impl UtreexodBackend {
}
self.process_block(block_height)?;
}
if self.chainstate.is_in_idb() {
if self.chainstate.is_in_ibd() {
info!("Leaving Initial Block Download at height {height}");
} else {
info!("New tip: {height}");
Expand Down Expand Up @@ -221,7 +221,7 @@ impl UtreexodBackend {
self.chainstate
.connect_block(&block_data.block, proof, inputs, del_hashes)?;
}
info!("Leaving ibd");
info!("Leaving IBD");
self.chainstate.toggle_ibd(false);
self.chainstate.flush()?;

Expand Down
2 changes: 1 addition & 1 deletion crates/floresta-wire/src/p2p_wire/chain_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ where
}

pub async fn run(&mut self) -> Result<(), WireError> {
info!("Starting ibd, selecting the best chain");
info!("Starting IBD, selecting the best chain");

loop {
while let Ok(notification) = timeout(Duration::from_secs(1), self.node_rx.recv()).await
Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-wire/src/p2p_wire/running_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ where
done_flag.send(()).unwrap();

// we haven't finished the backfill yet, save the current state for the next run
if chain.is_in_idb() {
if chain.is_in_ibd() {
let acc = chain.get_acc();
let tip = chain.get_height().unwrap();
let mut ser_acc = Vec::new();
Expand Down Expand Up @@ -766,7 +766,7 @@ where
return Err(WireError::PeerMisbehaving);
}

if !self.chain.is_in_idb() {
if !self.chain.is_in_ibd() {
// Convert to BitcoinNodeHashes, from rustreexo
let del_hashes: Vec<_> = del_hashes.into_iter().map(Into::into).collect();

Expand Down Expand Up @@ -912,7 +912,7 @@ where
self.chain.accept_header(*header)?;
}

if self.chain.is_in_idb() {
if self.chain.is_in_ibd() {
let blocks = headers.iter().map(|header| header.block_hash()).collect();
self.request_blocks(blocks).await?;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/floresta-wire/src/p2p_wire/sync_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
.0;

if validation_index == best_block {
info!("ibd finished, switching to normal operation mode");
info!("IBD is finished, switching to normal operation mode");
self.chain.toggle_ibd(false);
break;
}
Expand Down
6 changes: 3 additions & 3 deletions crates/floresta-wire/src/p2p_wire/tests/sync_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod tests {
chain.get_best_block().unwrap().1,
essentials.headers[9].block_hash()
);
assert!(!chain.is_in_idb());
assert!(!chain.is_in_ibd());
}

#[tokio::test]
Expand All @@ -131,7 +131,7 @@ mod tests {
chain.get_best_block().unwrap().1,
essentials.headers[6].block_hash()
);
assert!(!chain.is_in_idb());
assert!(!chain.is_in_ibd());
}

#[tokio::test]
Expand Down Expand Up @@ -177,6 +177,6 @@ mod tests {
chain.get_best_block().unwrap().1,
essentials.headers[9].block_hash()
);
assert!(!chain.is_in_idb());
assert!(!chain.is_in_ibd());
}
}
2 changes: 1 addition & 1 deletion crates/floresta/examples/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async fn main() {
// synced by calling the is_in_ibd method.
loop {
// Wait till the node is synced
if !chain.is_in_idb() {
if !chain.is_in_ibd() {
break;
}
// Sleep for 10 seconds, and check again
Expand Down
6 changes: 3 additions & 3 deletions florestad/src/json_rpc/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl RpcImpl {
pub(super) fn get_blockchain_info(&self) -> Result<GetBlockchainInfoRes, RpcError> {
let (height, hash) = self.chain.get_best_block().unwrap();
let validated = self.chain.get_validation_index().unwrap();
let ibd = self.chain.is_in_idb();
let ibd = self.chain.is_in_ibd();
let latest_header = self.chain.get_block_header(&hash).unwrap();
let latest_work = latest_header.work();
let latest_block_time = latest_header.time;
Expand Down Expand Up @@ -228,8 +228,8 @@ impl RpcImpl {
return Ok(serde_json::to_value(txout).unwrap());
}

// if we are on ibd, we don't have any filters to find this txout.
if self.chain.is_in_idb() {
// if we are on IBD, we don't have any filters to find this txout.
if self.chain.is_in_ibd() {
return Err(RpcError::InInitialBlockDownload);
}

Expand Down
2 changes: 1 addition & 1 deletion florestad/src/json_rpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl RpcImpl {

fn rescan(&self, _rescan: u32) -> Result<bool> {
// if we are on ibd, we don't have any filters to rescan
if self.chain.is_in_idb() {
if self.chain.is_in_ibd() {
return Err(Error::InInitialBlockDownload);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/floresta-cli/addnode-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GetAddnodeIDBErrorTest(FlorestaTestFramework):
]
electrum_addrs = ["0.0.0.0:50001", "0.0.0.0:50002"]
rpc_addrs = ["0.0.0.0:18442", "0.0.0.0:18443"]
node_idb_error = "Node is in initial block download, wait until it's finished"
node_ibd_error = "Node is in initial block download, wait until it's finished"

def set_test_params(self):
"""
Expand Down Expand Up @@ -93,7 +93,7 @@ def run_test(self):
assert success
except JSONRPCError as exc:
assert exc.code == -32603
assert exc.message == GetAddnodeIDBErrorTest.node_idb_error
assert exc.message == GetAddnodeIDBErrorTest.node_ibd_error
assert exc.data is None
finally:
# stop nodes
Expand Down