Ejemplo n.º 1
0
  private Trie parseGenesis() {
    JSONParser parser = new JSONParser();
    JSONObject genesisMap = null;
    try {
      genesisMap = (JSONObject) parser.parse(GENESIS_JSON);
    } catch (ParseException e) {
      e.printStackTrace();
      System.exit(-1);
    }

    Set<String> keys = genesisMap.keySet();

    Trie state = new SecureTrie(null);

    for (String key : keys) {

      JSONObject val = (JSONObject) genesisMap.get(key);
      String denom = (String) val.keySet().toArray()[0];
      String value = (String) val.values().toArray()[0];

      BigInteger wei =
          Denomination.valueOf(denom.toUpperCase()).value().multiply(new BigInteger(value));

      AccountState acctState = new AccountState(BigInteger.ZERO, wei);
      byte[] keyB = Hex.decode(key);
      state.update(keyB, acctState.getEncoded());
      premine.put(wrap(keyB), acctState);
    }

    return state;
  }
Ejemplo n.º 2
0
  private Genesis() {
    super(
        PARENT_HASH,
        UNCLES_HASH,
        COINBASE,
        LOG_BLOOM,
        DIFFICULTY,
        NUMBER,
        GAS_LIMIT,
        GAS_USED,
        TIMESTAMP,
        EXTRA_DATA,
        MIX_HASH,
        NONCE,
        null,
        null);

    // The proof-of-concept series include a development pre-mine, making the state root hash
    // some value stateRoot. The latest documentation should be consulted for the value of the state
    // root.
    Trie state = parseGenesis();
    setStateRoot(state.getRootHash());
  }