syn: Remove `bpf` target support in `hash` feature (#3078)
This commit is contained in:
parent
0a1d458c7b
commit
fd6174a88d
|
@ -27,6 +27,8 @@ The minor version will be incremented upon a breaking change and the patch versi
|
|||
|
||||
### Breaking
|
||||
|
||||
- syn: Remove `bpf` target support in `hash` feature ([#3078](https://github.com/coral-xyz/anchor/pull/3078)).
|
||||
|
||||
## [0.30.1] - 2024-06-20
|
||||
|
||||
### Features
|
||||
|
|
|
@ -78,11 +78,6 @@ impl Hash {
|
|||
Hash(<[u8; HASH_BYTES]>::try_from(hash_slice).unwrap())
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "bpf")]
|
||||
pub const fn new_from_array(hash_array: [u8; HASH_BYTES]) -> Self {
|
||||
Self(hash_array)
|
||||
}
|
||||
|
||||
pub fn to_bytes(self) -> [u8; HASH_BYTES] {
|
||||
self.0
|
||||
}
|
||||
|
@ -92,28 +87,9 @@ impl Hash {
|
|||
pub fn hashv(vals: &[&[u8]]) -> Hash {
|
||||
// Perform the calculation inline, calling this from within a program is
|
||||
// not supported
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
{
|
||||
let mut hasher = Hasher::default();
|
||||
hasher.hashv(vals);
|
||||
hasher.result()
|
||||
}
|
||||
// Call via a system call to perform the calculation
|
||||
#[cfg(target_arch = "bpf")]
|
||||
{
|
||||
extern "C" {
|
||||
fn sol_sha256(vals: *const u8, val_len: u64, hash_result: *mut u8) -> u64;
|
||||
}
|
||||
let mut hash_result = [0; HASH_BYTES];
|
||||
unsafe {
|
||||
sol_sha256(
|
||||
vals as *const _ as *const u8,
|
||||
vals.len() as u64,
|
||||
&mut hash_result as *mut _ as *mut u8,
|
||||
);
|
||||
}
|
||||
Hash::new_from_array(hash_result)
|
||||
}
|
||||
let mut hasher = Hasher::default();
|
||||
hasher.hashv(vals);
|
||||
hasher.result()
|
||||
}
|
||||
|
||||
/// Return a Sha256 hash for the given data.
|
||||
|
|
Loading…
Reference in New Issue