pub struct PreimageKey { /* private fields */ }Expand description
A preimage key is a 32-byte value that identifies a preimage that may be fetched from the oracle.
Layout:
| Bits | Description |
|---|---|
| [0, 1) | Type byte |
| [1, 32) | Data |
Implementations§
Source§impl PreimageKey
impl PreimageKey
Sourcepub fn new(key: [u8; 32], key_type: PreimageKeyType) -> Self
pub fn new(key: [u8; 32], key_type: PreimageKeyType) -> Self
Creates a new PreimageKey from a 32-byte value and a PreimageKeyType. The 32-byte value will be truncated to 31 bytes by taking the low-order 31 bytes.
Sourcepub fn new_local(local_ident: u64) -> Self
pub fn new_local(local_ident: u64) -> Self
Creates a new local PreimageKey from a 64-bit local identifier. The local identifier will be written into the low-order 8 bytes of the big-endian 31-byte data field.
Sourcepub fn new_keccak256(digest: [u8; 32]) -> Self
pub fn new_keccak256(digest: [u8; 32]) -> Self
Creates a new keccak256 PreimageKey from a 32-byte keccak256 digest. The digest will be truncated to 31 bytes by taking the low-order 31 bytes.
Sourcepub fn new_precompile(precompile_addr: [u8; 20], input: &[u8]) -> Self
pub fn new_precompile(precompile_addr: [u8; 20], input: &[u8]) -> Self
Creates a new precompile PreimageKey from a precompile address and input. The key will be
constructed as keccak256(precompile_addr ++ input), and then the high-order byte of the
digest will be set to the type byte.
Sourcepub const fn key_type(&self) -> PreimageKeyType
pub const fn key_type(&self) -> PreimageKeyType
Returns the PreimageKeyType for the PreimageKey.
Sourcepub const fn key_value(&self) -> U256
pub const fn key_value(&self) -> U256
Returns the value of the PreimageKey as a U256.
Trait Implementations§
Source§impl Clone for PreimageKey
impl Clone for PreimageKey
Source§fn clone(&self) -> PreimageKey
fn clone(&self) -> PreimageKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more