Skip to content

Commit a8a1452

Browse files
committed
revert chain history change
1 parent fdb547d commit a8a1452

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ resolver = "3"
33
members = [
44
# Binaries
55
"binaries/cuprated",
6-
"binaries/p2p_connect",
76

87
# Consensus
98
"consensus",
@@ -63,7 +62,6 @@ members = [
6362
default-members = [
6463
# Binaries
6564
"binaries/cuprated",
66-
"binaries/p2p_connect",
6765

6866
# Consensus
6967
"consensus",

binaries/cuprated/src/rpc/handlers/bin.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,10 @@ async fn get_blocks(
128128
removed_pool_txids: Default::default(),
129129
};
130130

131-
/*
132131
if !get_blocks {
133132
return Ok(resp);
134133
}
135134

136-
*/
137135

138136
if let Some(block_id) = block_hashes.first() {
139137
let (height, hash) = helper::top_height(&mut state).await?;

storage/blockchain/src/free.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ pub fn open(config: Config) -> Result<Blockchain, heed::Error> {
9393
// <https://docs.rs/heed/0.20.0/heed/struct.EnvOpenOptions.html#method.open>
9494
unsafe { env_open_options.open(&config.data_dir)? }
9595
};
96-
/*
97-
Hello,
9896

99-
I wouldn't class
100-
*/
10197
let (block_heights, key_images, pre_rct_outputs, tx_ids, tx_outputs, alt_chain_infos, alt_block_heights, alt_blocks_info, alt_block_blobs, alt_transaction_blobs, alt_transaction_infos) = {
10298
let mut rw_tx = env.write_txn()?;
10399

storage/blockchain/src/ops/alt_block/chain.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,36 @@ pub fn update_alt_chain_info(
2929
Err(e) => Err(e)?,
3030
};
3131

32-
let current_chain_id = alt_block_height.chain_id;
33-
34-
let mut info = db.alt_chain_infos
35-
.get(tx_rw, &current_chain_id)?
36-
.unwrap_or(AltChainInfo {
37-
parent_chain: parent_chain.into(),
38-
common_ancestor_height: 0,
39-
chain_height: 0,
40-
});
32+
let Some(mut info) = db.alt_chain_infos
33+
.get(tx_rw, &alt_block_height.chain_id)?
34+
else {
35+
db.alt_chain_infos.put(
36+
tx_rw,
37+
&alt_block_height.chain_id,
38+
&AltChainInfo {
39+
parent_chain: parent_chain.into(),
40+
common_ancestor_height: alt_block_height.height.checked_sub(1).unwrap(),
41+
chain_height: alt_block_height.height + 1,
42+
},
43+
)?;
44+
45+
return Ok(());
46+
};
4147

4248
if info.chain_height < alt_block_height.height + 1 {
49+
// If the chain height is increasing we only need to update the chain height.
4350
info.chain_height = alt_block_height.height + 1;
51+
} else {
52+
// If the chain height is not increasing we are popping blocks and need to update the
53+
// split point.
54+
info.common_ancestor_height = alt_block_height.height.checked_sub(1).unwrap();
55+
info.parent_chain = parent_chain.into();
4456
}
4557

46-
db.alt_chain_infos.put(tx_rw, &current_chain_id, &info)?;
58+
db.alt_chain_infos
59+
.put(tx_rw, &alt_block_height.chain_id, &info)?;
60+
61+
db.alt_chain_infos.put(tx_rw, &alt_block_height.chain_id, &info)?;
4762

4863
Ok(())
4964
}

0 commit comments

Comments
 (0)