// namehash generates a hash from a name that can be used to look up the name in ENS
namehash generates a hash from a name that can be used to look up the name in ENS
namehash generates a hash from a name that can be used to look up the name in ENS
fn namehash(name: &str) -> Vec<u8> {
    let mut node = vec![0u8; 32];
    if name.is_empty() {
        return node;
    }
    let n = name.clone().to_lowercase();
    let mut labels: Vec<&str> = n.as_str().split(".").collect();
    labels.reverse();
    for label in labels.iter() {
        let mut labelhash = [0u8; 32];
        let mut hasher = Keccak::v256();
        hasher.update(label.as_bytes());
        hasher.finalize(&mut labelhash);
        node.append(&mut labelhash.to_vec());
        labelhash = [0u8; 32];
        let mut hasher = Keccak::v256();
        hasher.update(node.as_slice());
        hasher.finalize(&mut labelhash);
        node = labelhash.to_vec();
    }
    node
}
fn namehash ( name : & str ) -> Vec < u8 > { let mut node = vec ! [ 0u8 32 ] ; if name . is_empty ( ) { return node ; } let n = name . clone ( ) . to_lowercase ( ) ; let mut labels : Vec < & str > = n . as_str ( ) . split ( " " ) . collect ( ) ; labels . reverse ( ) ; for label in labels . iter ( ) { let mut labelhash = [ 0u8 ; 32 ] ; let mut hasher = Keccak :: v256 ( ) ; hasher . update ( label . as_bytes ( ) ) ; hasher . finalize ( & mut labelhash ) ; node . append ( & mut labelhash . to_vec ( ) ) ; labelhash = [ 0u8 ; 32 ] ; let mut hasher = Keccak :: v256 ( ) ; hasher . update ( node . as_slice ( ) ) ; hasher . finalize ( & mut labelhash ) ; node = labelhash . to_vec ( ) ; } node }
namehash generates a hash from a name that can be used to look up the name in ENS
namehash generates a hash from a name that can be used to look up the name in ENS
name
&str