Exemplo n.º 1
0
  @Override
  public byte[] getStorageHash() {

    SecureTrie storageTrie = new SecureTrie(null);

    for (DataWord key : storage.keySet()) {

      DataWord value = storage.get(key);

      storageTrie.update(key.getData(), RLP.encodeElement(value.getNoLeadZeroesData()));
    }

    return storageTrie.getRootHash();
  }
Exemplo n.º 2
0
  @Override
  public byte[] getEncoded() {

    byte[][] keys = new byte[storage.size()][];
    byte[][] values = new byte[storage.size()][];

    int i = 0;
    for (DataWord key : storage.keySet()) {

      DataWord value = storage.get(key);

      keys[i] = RLP.encodeElement(key.getData());
      values[i] = RLP.encodeElement(value.getNoLeadZeroesData());

      ++i;
    }

    byte[] rlpKeysList = RLP.encodeList(keys);
    byte[] rlpValuesList = RLP.encodeList(values);
    byte[] rlpCode = RLP.encodeElement(code);

    return RLP.encodeList(rlpKeysList, rlpValuesList, rlpCode);
  }