Package org.ethereum.trie

Examples of org.ethereum.trie.Trie.update()


    Trie state = new TrieImpl(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.
    for (String address : premine) {
      AccountState acctState = new AccountState(BigInteger.ZERO, PREMINE_AMOUNT);
      state.update(Hex.decode(address), acctState.getEncoded());
        }

    setStateRoot(state.getRootHash());
    }
 
View Full Code Here


    private Trie generateGenesisState() {

        Trie trie = new TrieImpl(new MockDB());
        for (String address : Genesis.getPremine()) {
            AccountState acct = new AccountState(BigInteger.ZERO, BigInteger.valueOf(2).pow(200));
            trie.update(Hex.decode(address), acct.getEncoded());     
    }
        return trie;
    }
}
View Full Code Here

        byte[] cumGas      = Hex.decode("0272");

        TransactionReceipt tr = new TransactionReceipt(tx, postTxState, cumGas);

        Trie trie = new TrieImpl(new MockDB());
        trie.update(RLP.encodeInt(0), tr.getEncoded());
        String txTrieRoot = Hex.toHexString(trie.getRootHash());
        assertEquals(expected, txTrieRoot);
    }

    @Test  // calc state after applying first tx on genesis
View Full Code Here

        byte[] cowAddress = Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
        byte[] rlpEncodedState = trie.get(cowAddress);
        AccountState account_1 = new AccountState(rlpEncodedState);
        account_1.addToBalance(new BigInteger("-6260000000001000"));
        account_1.incrementNonce();
        trie.update(cowAddress, account_1.getEncoded());

        // Add contract to world state
        byte[] codeData = Hex.decode("61778e600054");
        AccountState account_2 = new AccountState(BigInteger.ZERO, BigInteger.valueOf(1000));
        account_2.setCodeHash(HashUtil.sha3(codeData));
View Full Code Here

        // Add contract to world state
        byte[] codeData = Hex.decode("61778e600054");
        AccountState account_2 = new AccountState(BigInteger.ZERO, BigInteger.valueOf(1000));
        account_2.setCodeHash(HashUtil.sha3(codeData));
        byte[] contractAddress = Hex.decode("77045e71a7a2c50903d88e564cd72fab11e82051"); // generated based on sender + nonce
        trie.update(contractAddress, account_2.getEncoded());

//        this is saved in the db
//        trie.update(HashUtil.sha3(codeData), codeData);

        // Update miner in world state
View Full Code Here

//        trie.update(HashUtil.sha3(codeData), codeData);

        // Update miner in world state
        byte[] minerAddress = Hex.decode("4c5f4d519dff3c16f0d54b6866e256fbbbc1a600");
        AccountState account_3 = new AccountState(BigInteger.ZERO, new BigInteger("1506260000000000000"));
        trie.update(minerAddress, account_3.getEncoded());
       
        assertEquals(expected,  Hex.toHexString(trie.getRootHash()));


        /* *** GROSS DATA ***
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.