@Override
  public void decode(byte[] rlpCode) {
    RLPList data = RLP.decode2(rlpCode);
    RLPList rlpList = (RLPList) data.get(0);

    RLPList keys = (RLPList) rlpList.get(0);
    RLPList values = (RLPList) rlpList.get(1);
    RLPElement code = rlpList.get(2);

    for (int i = 0; i < keys.size(); ++i) {

      RLPItem key = (RLPItem) keys.get(i);
      RLPItem value = (RLPItem) values.get(i);

      storage.put(new DataWord(key.getRLPData()), new DataWord(value.getRLPData()));
    }

    this.code = (code.getRLPData() == null) ? ByteUtil.EMPTY_BYTE_ARRAY : code.getRLPData();
  }
示例#2
0
 public static String rlpDecodeString(RLPElement elem) {
   byte[] b = elem.getRLPData();
   if (b == null) return null;
   return new String(b);
 }
示例#3
0
 public static int rlpDecodeInt(RLPElement elem) {
   byte[] b = elem.getRLPData();
   if (b == null) return 0;
   return ByteUtil.byteArrayToInt(b);
 }