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: 3 additions & 1 deletion program/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
//! [SHA-256]: https://en.wikipedia.org/wiki/SHA-2
//! [`Hash`]: struct@Hash

#[allow(deprecated)]
pub use solana_sha256_hasher::extend_and_hash;
pub use {
solana_hash::{Hash, ParseHashError, HASH_BYTES},
solana_sha256_hasher::{extend_and_hash, hash, hashv, Hasher},
solana_sha256_hasher::{hash, hashv, Hasher},
};
1 change: 1 addition & 0 deletions sha256-hasher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn hash(val: &[u8]) -> Hash {
}

/// Return the hash of the given hash extended with the given value.
#[deprecated(since = "2.3.0", note = "Use `hashv(&[hash.as_ref(), val])` directly")]
pub fn extend_and_hash(id: &Hash, val: &[u8]) -> Hash {
let mut hash_data = id.as_ref().to_vec();
hash_data.extend_from_slice(val);
Expand Down
4 changes: 2 additions & 2 deletions shred-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! [shred]: https://solana.com/docs/terminology#shred

use {solana_hard_forks::HardForks, solana_hash::Hash, solana_sha256_hasher::extend_and_hash};
use {solana_hard_forks::HardForks, solana_hash::Hash, solana_sha256_hasher::hashv};

pub fn version_from_hash(hash: &Hash) -> u16 {
let hash = hash.as_ref();
Expand All @@ -27,7 +27,7 @@ pub fn compute_shred_version(genesis_hash: &Hash, hard_forks: Option<&HardForks>
if let Some(hard_forks) = hard_forks {
for &(slot, count) in hard_forks.iter() {
let buf = [slot.to_le_bytes(), (count as u64).to_le_bytes()].concat();
hash = extend_and_hash(&hash, &buf);
hash = hashv(&[hash.as_ref(), &buf]);
}
}

Expand Down
Loading