Brunet.Services.Dht.Dht.MapToRing C# (CSharp) Méthode

MapToRing() public méthode

Get the hash of the first key and add 1/DEGREE * Address space to each successive key. The results are the positions in the ring where the data should be stored.
public MapToRing ( byte key ) : MemBlock[]
key byte The key to index.
Résultat MemBlock[]
    public MemBlock[] MapToRing(byte[] key) {
      MemBlock[] targets = new MemBlock[DEGREE];
      // Setup the first key
      HashAlgorithm algo = new SHA1CryptoServiceProvider();
      byte[] target = algo.ComputeHash(key);
      Address.SetClass(target, AHAddress._class);
      targets[0] = MemBlock.Reference(target, 0, Address.MemSize);

      // Setup the rest of the keys
      BigInteger inc_addr = Address.Full/DEGREE;
      BigInteger curr_addr = new BigInteger(targets[0]);
      for (int k = 1; k < targets.Length; k++) {
        curr_addr = curr_addr + inc_addr;
        target = Address.ConvertToAddressBuffer(curr_addr);
        Address.SetClass(target, AHAddress._class);
        targets[k] = target;
      }
      return targets;
    }