Package org.ethereum.vm

Examples of org.ethereum.vm.DataWord


        this.storage = new HashMap<>();
        List<DataWord> keys = new ArrayList<>(storage.keySet());
        Collections.sort(keys);
        for (DataWord key : keys) {
            DataWord value = storage.get(key);
            this.storage.put(Hex.toHexString(key.getNoLeadZeroesData()),
                    Hex.toHexString(value.getNoLeadZeroesData()));
        }
    }
View Full Code Here


        AccountState state = getAccountState(addr);
        if (state == null) return null;

        ContractDetails details = getContractDetails(addr);
        DataWord value = details.get(key);

        return value;
    }
View Full Code Here

      storageValues = new ArrayList<>();
    }

    for (int i = 0; i < keys.size(); ++i) {
      RLPItem rlpItem = (RLPItem) keys.get(i);
      storageKeys.add(new DataWord(rlpItem.getRLPData()));
    }

    for (int i = 0; i < values.size(); ++i) {
      RLPItem rlpItem = (RLPItem) values.get(i);
      storageValues.add(new DataWord(rlpItem.getRLPData()));
    }

    for (int i = 0; i < keys.size(); ++i) {
      DataWord key = storageKeys.get(i);
      DataWord value = storageValues.get(i);
            storageTrie.update(key.getData(), RLP.encodeElement(value.getNoLeadZeroesData()));
    }

    this.code = code.getRLPData();
    this.rlpEncoded = rlpCode;
  }
View Full Code Here

      byte[][] keys = new byte[size][];
      byte[][] values = new byte[size][];

      for (int i = 0; i < size; ++i) {
        DataWord key = storageKeys.get(i);
        keys[i] = RLP.encodeElement(key.getData());
      }
      for (int i = 0; i < size; ++i) {
        DataWord value = storageValues.get(i);
        values[i] = RLP.encodeElement(value.getNoLeadZeroesData());
      }

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

      return columns.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
      DataWord key = (DataWord) this.data.keySet().toArray()[rowIndex];
     
      if(columnIndex == 0) {
        return getDataWithEncoding(key.getData(), keyEncodingType);
      }
      else {
        DataWord value = this.data.get(key);
        return getDataWithEncoding(value.getData(), valueEncodingType);
      }
    }
View Full Code Here

                 stop
     */

        int expectedGas = 438;

        DataWord key1 = new DataWord(999);
        DataWord value1 = new DataWord(3);

        // Set contract into Database
        String callerAddr   = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826";
        String contractAddr = "77045e71a7a2c50903d88e564cd72fab11e82051";
        String code         = "6103e75460005260006000511115630000004c576001600051036103e755600060006000600060007377045e71a7a2c50903d88e564cd72fab11e820516008600a5a0402f1630000004c565b00";
View Full Code Here


        System.out.println("*** Used gas: " + program.getResult().getGasUsed());


        DataWord value_1 = repository.getStorageValue(contractA_addr_bytes, new DataWord(00));
        DataWord value_2 = repository.getStorageValue(contractA_addr_bytes, new DataWord(01));


        repository.close();
        assertEquals(expectedVal_1, value_1.longValue());
        assertEquals(expectedVal_2, value_2.longValue());

        // TODO: check that the value pushed after exec is 1
    }
View Full Code Here

        System.out.println();
        System.out.println("============ Results ============");
        System.out.println("*** Used gas: " + program.getResult().getGasUsed());

        DataWord value1 = program.memoryLoad(new DataWord(32));
        DataWord value2 = program.memoryLoad(new DataWord(64));
        DataWord value3 = program.memoryLoad(new DataWord(96));
        DataWord value4 = program.memoryLoad(new DataWord(128));
        DataWord value5 = program.memoryLoad(new DataWord(160));
        DataWord value6 = program.memoryLoad(new DataWord(192));

        repository.close();

        assertEquals(expectedVal_1, value1.longValue());
        assertEquals(expectedVal_2, value2.longValue());
        assertEquals(expectedVal_3, value3.longValue());
        assertEquals(expectedVal_4, value4.longValue());
        assertEquals(expectedVal_5, value5.longValue());
        assertEquals(expectedVal_6, value6.longValue());

        // TODO: check that the value pushed after exec is 1
    }
View Full Code Here

        System.out.println();
        System.out.println("============ Results ============");
        System.out.println("*** Used gas: " + program.getResult().getGasUsed());

        DataWord memValue1 = program.memoryLoad(new DataWord(0));
        DataWord memValue2 = program.memoryLoad(new DataWord(32));

        DataWord storeValue1 = repository.getStorageValue(contractB_addr_bytes, new DataWord(00));

        repository.close();

        assertEquals("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", memValue1.toString());
        assertEquals("aaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa", memValue2.toString());

        assertEquals("0x1", storeValue1.shortHex());

        // TODO: check that the value pushed after exec is 1
    }
View Full Code Here

    @Test // storage set/get
    public void test9() {

        String addr = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826";
        byte[] keyBytes = Hex.decode("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
        DataWord key = new DataWord(keyBytes);

        Repository repository = worldManager.getRepository();

        DataWord value = repository.getStorageValue(Hex.decode(addr), key);
        assertNull(value);
    }
View Full Code Here

TOP

Related Classes of org.ethereum.vm.DataWord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.