diff --git a/rust/examples/dhtnode.rs b/rust/examples/dhtnode.rs index 8ab4001a6c53547425417179a4bd508227671407..dd7c4a25cc8c2df3d7092eb252422dc2fb91dddd 100644 --- a/rust/examples/dhtnode.rs +++ b/rust/examples/dhtnode.rs @@ -57,18 +57,16 @@ fn main() { }; let ptr = &mut handler as *mut _ as *mut c_void; - println!("Start listening /foo"); - let token = dht.listen(&InfoHash::get("foo"), value_cb, ptr); - thread::sleep(ten_secs); - println!("Stop listening /foo"); - dht.cancel_listen(&InfoHash::get("foo"), token); + //println!("Start listening /foo"); + //let token = dht.listen(&InfoHash::get("foo"), value_cb, ptr); + //thread::sleep(ten_secs); + //println!("Stop listening /foo"); + //dht.cancel_listen(&InfoHash::get("foo"), token); //loop { println!("Get /alice"); dht.get(&InfoHash::get("alice"), get_cb, done_cb, ptr); let v = Value::new("hi!"); - // TODO put value - // TODO check drop - dht.put(&InfoHash::get("bob"), Box::into_raw(v), done_cb, ptr); + dht.put(&InfoHash::get("bob"), v, done_cb, ptr); //thread::sleep(ten_secs); //} } \ No newline at end of file diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 66945aa3dbc452a753dd8bcb4104ee4d780eb876..d9b6adfd30dfb3a59fb043e51f87929697354b18 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -112,12 +112,12 @@ impl DhtRunner { } } - pub fn put(&mut self, h: &InfoHash, v: *const Value, + pub fn put(&mut self, h: &InfoHash, v: Box<Value>, done_cb: extern fn(bool, *mut c_void), cb_user_data: *mut c_void) { unsafe { - dht_runner_put(&mut *self, h, v, done_cb, cb_user_data) + dht_runner_put(&mut *self, h, &*v, done_cb, cb_user_data) } }