Created
March 23, 2023 02:47
-
-
Save Ma233/aa2f4fce7400f4173e40b4eaaba8ee93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async fn test_croath() -> Result<()> { | |
let croath = Did::from_str("0xf7fea1722f9b27b0666919a5664bab486a4b18d3")?; | |
let no_41d = Did::from_str("0x0298ba2b72ef040bbd99398f96594e8d8c0d0607")?; | |
let vnode = Did::from_str("0xec472b3b5e00a33cd3b8ce91159e4d43350c3098")?; | |
let croath_dht = PeerRing::new(croath).await?; | |
{ | |
let mut successors = croath_dht.lock_successor()?; | |
successors.update(no_41d); | |
} | |
{ | |
let mut finger = croath_dht.lock_finger()?; | |
for i in 0..156 { | |
finger.set(i, no_41d); | |
} | |
finger.set(1, croath); | |
} | |
{ | |
let successors = { | |
croath_dht | |
.lock_successor() | |
.map(|ss| ss.list()) | |
.unwrap_or_default() | |
.into_iter() | |
.map(|s| s.to_string()) | |
.collect::<Vec<_>>() | |
}; | |
dbg!(successors); | |
} | |
{ | |
let finger_table = croath_dht | |
.lock_finger() | |
.map(|ft| { | |
let finger = ft.list().iter().map(|x| x.map(|did| did.to_string())); | |
compress_iter(finger) | |
}) | |
.unwrap_or_default(); | |
dbg!(finger_table); | |
} | |
dbg!(croath_dht.vnode_lookup(vnode).await); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment