当前位置: 首页>>代码示例>>Java>>正文


Java TrieImpl类代码示例

本文整理汇总了Java中org.ethereum.trie.TrieImpl的典型用法代码示例。如果您正苦于以下问题:Java TrieImpl类的具体用法?Java TrieImpl怎么用?Java TrieImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TrieImpl类属于org.ethereum.trie包,在下文中一共展示了TrieImpl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseTxs

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
private void parseTxs(byte[] expectedRoot, RLPList txReceipts) {

        this.txsState = new TrieImpl(null);
        for (int i = 0; i < txReceipts.size(); i++) {
        	RLPElement rlpTxReceipt = txReceipts.get(i);
            RLPElement txData = ((RLPList)rlpTxReceipt).get(0);
            
            // YP 4.3.1
            RLPElement pstTxState = ((RLPList)rlpTxReceipt).get(1);
            RLPElement cummGas    = ((RLPList)rlpTxReceipt).get(2);

            Transaction tx = new Transaction(txData.getRLPData());
            this.transactionsList.add(tx);
            TransactionReceipt txReceipt =
                new TransactionReceipt(tx, pstTxState.getRLPData(), cummGas.getRLPData());
            this.addTxReceipt(i, txReceipt);
        }
        String calculatedRoot = Hex.toHexString(txsState.getRootHash());
        if(!calculatedRoot.equals(Hex.toHexString(expectedRoot)))
			logger.error("Added tx receipts don't match the given txsStateRoot");
    }
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:22,代码来源:Block.java

示例2: parseTxs

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
private byte[] parseTxs(RLPList txTransactions, boolean validate) {

        Trie<byte[]> txsState = new TrieImpl();
        for (int i = 0; i < txTransactions.size(); i++) {
            RLPElement transactionRaw = txTransactions.get(i);
            Transaction tx = new Transaction(transactionRaw.getRLPData());
            if (validate) tx.verify();
            this.transactionsList.add(tx);
            txsState.put(RLP.encodeInt(i), transactionRaw.getRLPData());
        }
        return txsState.getRootHash();
    }
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:Block.java

示例3: calcTxTrie

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
public static byte[] calcTxTrie(List<Transaction> transactions) {

        Trie txsState = new TrieImpl();

        if (transactions == null || transactions.isEmpty())
            return HashUtil.EMPTY_TRIE_HASH;

        for (int i = 0; i < transactions.size(); i++) {
            txsState.put(RLP.encodeInt(i), transactions.get(i).getEncoded());
        }
        return txsState.getRootHash();
    }
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:BlockchainImpl.java

示例4: calcReceiptsTrie

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
public static byte[] calcReceiptsTrie(List<TransactionReceipt> receipts) {
    Trie receiptsTrie = new TrieImpl();

    if (receipts == null || receipts.isEmpty())
        return HashUtil.EMPTY_TRIE_HASH;

    for (int i = 0; i < receipts.size(); i++) {
        receiptsTrie.put(RLP.encodeInt(i), receipts.get(i).getReceiptTrieEncoded());
    }
    return receiptsTrie.getRootHash();
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:12,代码来源:BlockchainImpl.java

示例5: generateGenesisState

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
private Trie generateGenesisState() {

        Trie<byte[]> trie = new TrieImpl();
        Genesis genesis = (Genesis)Genesis.getInstance();
        for (ByteArrayWrapper key : genesis.getPremine().keySet()) {
            trie.put(key.getData(), genesis.getPremine().get(key).accountState.getEncoded());
        }

        return trie;
    }
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:11,代码来源:StateTest.java

示例6: RepositoryImpl

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
public RepositoryImpl(String blockChainDbName, String detailsDbName, String stateDbName) {
	chainDB 			= new DatabaseImpl(blockChainDbName);
    detailsDB     		= new DatabaseImpl(detailsDbName);
    contractDetailsDB 	= new TrackDatabase(detailsDB);
    stateDB 			= new DatabaseImpl(stateDbName);
    worldState 			= new TrieImpl(stateDB.getDb());
    accountStateDB 		= new TrackTrie(worldState);
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:9,代码来源:RepositoryImpl.java

示例7: getStorageHash

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
public byte[] getStorageHash() {

    	storageTrie = new TrieImpl(null);
        // calc the trie for root hash
        for (int i = 0; i < storageKeys.size(); ++i){
			storageTrie.update(storageKeys.get(i).getData(), RLP
					.encodeElement(storageValues.get(i).getNoLeadZeroesData()));
        }
        return storageTrie.getRootHash();
    }
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:11,代码来源:ContractDetails.java

示例8: Genesis

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
private Genesis() {
super(PARENT_HASH, UNCLES_HASH, COINBASE, DIFFICULTY,
		NUMBER, MIN_GAS_PRICE, GAS_LIMIT, GAS_USED, TIMESTAMP,
		EXTRA_DATA, NONCE, null, null);

Trie state = new TrieImpl(null);
      // The proof-of-concept series include a development premine, 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();
	acctState.addToBalance(PREMINE_AMOUNT);
	state.update(Hex.decode(address), acctState.getEncoded());
      }
setStateRoot(state.getRootHash());
  }
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:16,代码来源:Genesis.java

示例9: generateGenesisState

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
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;
    }
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:10,代码来源:StateTest.java

示例10: testCalculatePostTxState

import org.ethereum.trie.TrieImpl; //导入依赖的package包/类
@Test  // right way to calc tx trie hash
public void testCalculatePostTxState() {

    /*    txTrieHash */
    String expected = "a77691cf47bec9021d3f027fc8ef2d51b758b600a79967154354b8e37108896f";
    Transaction tx = new Transaction(
            new byte[]{},
            Hex.decode("09184E72A000"),
            Hex.decode("03E8"),
            Hex.decode("0000000000000000000000000000000000000000"),
            Hex.decode("03e8"),
            Hex.decode("60016000546006601160003960066000f261778e600054")
    );
    byte[] cowPrivKey = Hex.decode("c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4");
    tx.sign(cowPrivKey);

    byte[] postTxState = Hex.decode("7fa5bd00f6e03b5a5718560f1e25179b227167585a3c3da06a48f554365fb527");
    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);

    /* *** GROSS DATA ***

    BlockData [
      hash=22cf863ab836a6f5c29389d2e77f4792a3b3b52908c98ed14b1cbe91491a3e36
      parentHash=77ef4fdaf389dca53236bcf7f72698e154eab2828f86fbc4fc6cd9225d285c89
      unclesHash=1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347
      coinbase=4c5f4d519dff3c16f0d54b6866e256fbbbc1a600
      stateHash=69c21ff84a5af0b53b11c61110a16d6ad43dad37b3eb29ae8e88c936eb06456a
      txTrieHash=a77691cf47bec9021d3f027fc8ef2d51b758b600a79967154354b8e37108896f
      difficulty=3ff000
      number=1
      minGasPrice=10000000000000
      gasLimit=999023
      gasUsed=626
      timestamp=1401979976 (2014.06.05 15:52:56)
      extraData=null
      nonce=0000000000000000000000000000000000000000000000005d439960040e4505

    TransactionReceipt[
       TransactionData [ hash=1ee6fa3149a5e9c09b54009eb6e108aaa7ecd79483d57eedcf2dff93a1505588  nonce=null,
           gasPrice=09184e72a000, gas=03e8, receiveAddress=0000000000000000000000000000000000000000, value=03e8,
           data=60016000546006601160003960066000f261778e600054, signatureV=27,
           signatureR=2b379f22050e3554c3fa5423d9040bb28dcc7f905300db4e67c03bcf9b27003c,
           signatureS=59f47793e050974e6b5fca2848b19925637b883a012693b54d712f1c4f74def5
      ]
      , postTxState=7fa5bd00f6e03b5a5718560f1e25179b227167585a3c3da06a48f554365fb527
      , cumulativeGas=0272]
    ]

    +++  4c5f4d519dff3c16f0d54b6866e256fbbbc1a600:
    +++  77045e71a7a2c50903d88e564cd72fab11e82051: $[61,77,8e,60,0,54] ([])
     *   cd2a3d9f938e13cd947ec05abc7fe734df8dd826: #1 1606938044258990275541962092341162602522202987522792835300376 (-6260000000001000)
      */
}
 
开发者ID:ethereumj,项目名称:ethereumj,代码行数:61,代码来源:StateTest.java


注:本文中的org.ethereum.trie.TrieImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。