public void AsyncGet(MemBlock key, Channel returns) {
if(!_online) {
throw new DhtException("The Node is (going) offline, DHT is offline.");
}
// create a GetState and map in our table map its queues to it
// so when we get a GetHandler we know which state to load
AsDhtGetState adgs = new AsDhtGetState(returns);
Channel[] q = new Channel[DEGREE];
lock(_adgs_table.SyncRoot) {
for (int k = 0; k < DEGREE; k++) {
Channel queue = new Channel(1);
_adgs_table[queue] = adgs;
q[k] = queue;
}
}
// Setting up our Channels
for (int k = 0; k < DEGREE; k++) {
Channel queue = q[k];
queue.EnqueueEvent += this.GetEnqueueHandler;
queue.CloseEvent += this.GetCloseHandler;
adgs.queueMapping[queue] = k;
}
// Sending off the request!
adgs.brunet_address_for_key = MapToRing(key);
for (int k = 0; k < DEGREE; k++) {
Address target = new AHAddress(adgs.brunet_address_for_key[k]);
AHSender s = new AHGreedySender(Node, target);
// 1024 is in there for backwards compatibility
_rpc.Invoke(s, q[k], "dht.Get", adgs.brunet_address_for_key[k], 1024, null);
}
}