Brunet.Graph.Graph.DhtQuery C# (CSharp) Method

DhtQuery() public method

public DhtQuery ( AHAddress from, byte key ) : int
from AHAddress
key byte
return int
    public int DhtQuery(AHAddress from, byte[] key)
    {
      // Done with getting connected to nearest neighbors
      // On to querying the Dht
      MemBlock[] endpoints = MapToRing(key);
      List<int> delays = new List<int>();
      foreach(MemBlock endpoint in endpoints) {
        AHAddress to = new AHAddress(endpoint);
        var request = SendPacket(from, to, AHHeader.Options.Greedy);
        var response = SendPacket(request[0].Destination, from, AHHeader.Options.Greedy);
        delays.Add(request[0].Delay + response[0].Delay);
      }
      delays.Sort();
      return delays[0];
      //return delays[delays.Count / 2 + 1];
    }