Blockchain 如何修改奇偶校验基中“哈希”中的字节?

Blockchain 如何修改奇偶校验基中“哈希”中的字节?,blockchain,parity-io,substrate,Blockchain,Parity Io,Substrate,给定基板运行时内生成的某些哈希值,如何修改或访问该哈希的各个字节?哈希特性输出具有AsRef和AsMut特性,允许您作为字节片[u8]与哈希交互: 或 哈希特性输出具有AsRef和AsMut特性,允许您作为字节片[u8]与哈希进行交互: 或 pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq { type Output: Member + MaybeSerializeDebug + AsRef<

给定基板运行时内生成的某些哈希值,如何修改或访问该哈希的各个字节?

哈希特性输出具有AsRef和AsMut特性,允许您作为字节片[u8]与哈希交互:

哈希特性输出具有AsRef和AsMut特性,允许您作为字节片[u8]与哈希进行交互:

pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq {
    type Output: Member + MaybeSerializeDebug + AsRef<[u8]> + AsMut<[u8]>;

    // ... removed for brevity
}
// Iterate over a hash
let hash1 = <T as system::Trait>::Hashing::hash(1);
for hash_byte in hash1.as_ref().iter() {
    // ... do something
}
// Add one to the first byte of a hash
let mut hash2 = <T as system::Trait>::Hashing::hash(2);
hash2.as_mut()[0] += 1;