Skip to content

Commit

Permalink
change comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ksrichard committed Nov 8, 2024
1 parent eb47fde commit 475a042
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions base_layer/core/src/chain_storage/lmdb_db/validator_node_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct ValidatorNodeStore<'a, Txn> {
db_validator_nodes_mapping: DatabaseRef,
}

impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn> {
impl<'a, Txn: Deref<Target=ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn> {
pub fn new(txn: &'a Txn, db_height_to_vn: DatabaseRef, idx_public_key_to_shard: DatabaseRef) -> Self {
Self {
txn,
Expand All @@ -70,15 +70,15 @@ impl ValidatorNodeStore<'_, WriteTransaction<'_>> {
validator.public_key.as_bytes(),
validator.commitment.as_bytes(),
])
.expect("insert: Composite key length is incorrect");
.expect("insert: Composite key length is incorrect");
lmdb_insert(self.txn, &self.db_validator_nodes, &key, &validator, "Validator node")?;

let key = ShardIdIndexKey::try_from_parts(&[
validator.public_key.as_bytes(),
height.to_be_bytes().as_slice(),
validator.commitment.as_bytes(),
])
.expect("insert: Composite key length is incorrect");
.expect("insert: Composite key length is incorrect");
lmdb_insert(
self.txn,
&self.db_validator_nodes_mapping,
Expand All @@ -100,15 +100,15 @@ impl ValidatorNodeStore<'_, WriteTransaction<'_>> {
public_key.as_bytes(),
commitment.as_bytes(),
])
.expect("delete: Composite key length is incorrect");
.expect("delete: Composite key length is incorrect");
lmdb_delete(self.txn, &self.db_validator_nodes, &key, "validator_nodes")?;

let key = ShardIdIndexKey::try_from_parts(&[
public_key.as_bytes(),
height.to_be_bytes().as_slice(),
commitment.as_bytes(),
])
.expect("delete: Composite key length is incorrect");
.expect("delete: Composite key length is incorrect");
lmdb_delete(
self.txn,
&self.db_validator_nodes_mapping,
Expand All @@ -119,7 +119,7 @@ impl ValidatorNodeStore<'_, WriteTransaction<'_>> {
}
}

impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn> {
impl<'a, Txn: Deref<Target=ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn> {
fn db_read_cursor(&self) -> Result<LmdbReadCursor<'a, ValidatorNodeEntry>, ChainStorageError> {
let cursor = self.txn.cursor(self.db_validator_nodes.clone())?;
let access = self.txn.access();
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn>
Ok(false)
}

/// Returns validator nodes until a given epoch.
/// Returns validator nodes count until a given epoch.
pub fn get_vn_count_until_epoch(
&self,
epoch: VnEpoch,
Expand All @@ -172,7 +172,7 @@ impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn>
Ok(result)
}

/// Returns validator nodes in a given epoch.
/// Returns validator nodes count in a given epoch.
pub fn get_vn_count_in_epoch(
&self,
epoch: VnEpoch,
Expand Down Expand Up @@ -217,7 +217,7 @@ impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn>
original_registration: vn.registration.clone(),
minimum_value_promise: vn.minimum_value_promise,
}));
},
}
None => return Ok(Vec::new()),
}

Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, Txn: Deref<Target = ConstTransaction<'a>>> ValidatorNodeStore<'a, Txn>
return Ok(None);
}
Some(s)
},
}
None => return Ok(None),
};

Expand Down Expand Up @@ -307,7 +307,7 @@ mod tests {

const DBS: &[&str] = &["validator_node_store", "validator_node_index"];

fn create_store<'a, Txn: Deref<Target = ConstTransaction<'a>>>(
fn create_store<'a, Txn: Deref<Target=ConstTransaction<'a>>>(
db: &TempLmdbDatabase,
txn: &'a Txn,
) -> ValidatorNodeStore<'a, Txn> {
Expand Down

0 comments on commit 475a042

Please sign in to comment.