Skip to content

Commit 2b76ea5

Browse files
committed
Reduce visibility of Hash struct contents
1 parent 3f559cc commit 2b76ea5

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

perf/src/sigverify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ mod tests {
740740
message.account_keys.push(pubkey1);
741741
message.account_keys.push(pubkey1);
742742
message.header.num_required_signatures = NUM_SIG as u8;
743-
message.recent_blockhash = Hash(pubkey1.to_bytes());
743+
message.recent_blockhash = Hash::new_from_array(pubkey1.to_bytes());
744744
let mut tx = Transaction::new_unsigned(message);
745745

746746
info!("message: {:?}", tx.message_data());

replica-lib/src/replica_accounts_server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl ReplicaAccountInfo {
3434
});
3535
ReplicaAccountInfo {
3636
account_meta,
37-
hash: stored_account_meta.hash.0.to_vec(),
37+
hash: stored_account_meta.hash.as_ref().to_vec(),
3838
data,
3939
}
4040
}
@@ -53,7 +53,7 @@ impl ReplicaAccountInfo {
5353
});
5454
ReplicaAccountInfo {
5555
account_meta,
56-
hash: cached_account.hash().0.to_vec(),
56+
hash: cached_account.hash().as_ref().to_vec(),
5757
data,
5858
}
5959
}

runtime/src/accounts_db.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4300,7 +4300,9 @@ impl AccountsDb {
43004300
hasher.update(owner.as_ref());
43014301
hasher.update(pubkey.as_ref());
43024302

4303-
Hash(<[u8; solana_sdk::hash::HASH_BYTES]>::try_from(hasher.finalize().as_slice()).unwrap())
4303+
Hash::new_from_array(
4304+
<[u8; solana_sdk::hash::HASH_BYTES]>::try_from(hasher.finalize().as_slice()).unwrap(),
4305+
)
43044306
}
43054307

43064308
fn bulk_assign_write_version(&self, count: usize) -> StoredMetaWriteVersion {

sdk/program/src/hash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const MAX_BASE58_LEN: usize = 44;
2626
AbiExample,
2727
)]
2828
#[repr(transparent)]
29-
pub struct Hash(pub [u8; HASH_BYTES]);
29+
pub struct Hash(pub(crate) [u8; HASH_BYTES]);
3030

3131
#[derive(Clone, Default)]
3232
pub struct Hasher {

transaction-status/src/parse_vote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ mod test {
163163
}
164164

165165
let lamports = 55;
166-
let hash = Hash([1; 32]);
166+
let hash = Hash::new_from_array([1; 32]);
167167
let vote = Vote {
168168
slots: vec![1, 2, 4],
169169
hash,
@@ -289,7 +289,7 @@ mod test {
289289
);
290290
assert!(parse_vote(&message.instructions[0], &keys[0..1]).is_err());
291291

292-
let proof_hash = Hash([2; 32]);
292+
let proof_hash = Hash::new_from_array([2; 32]);
293293
let instruction = vote_instruction::vote_switch(&keys[1], &keys[0], vote, proof_hash);
294294
let message = Message::new(&[instruction], None);
295295
assert_eq!(

0 commit comments

Comments
 (0)