• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TransactionReceipt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TransactionReceiptDTO

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public  TransactionReceiptDTO(Block block, TransactionInfo txInfo){
    TransactionReceipt receipt = txInfo.getReceipt();

    transactionHash = toJsonHex(receipt.getTransaction().getHash());
    transactionIndex = txInfo.getIndex();
    cumulativeGasUsed = ByteUtil.byteArrayToLong(receipt.getCumulativeGas());
    gasUsed = ByteUtil.byteArrayToLong(receipt.getGasUsed());
    if (receipt.getTransaction().getContractAddress() != null)
        contractAddress = toJsonHex(receipt.getTransaction().getContractAddress());
    logs = new JsonRpc.LogFilterElement[receipt.getLogInfoList().size()];
    if (block != null) {
        blockNumber = block.getNumber();
        blockHash = toJsonHex(txInfo.getBlockHash());
        for (int i = 0; i < logs.length; i++) {
            LogInfo logInfo = receipt.getLogInfoList().get(i);
            logs[i] = new JsonRpc.LogFilterElement(logInfo, block, txInfo.getIndex(),
                    txInfo.getReceipt().getTransaction(), i);
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:21,代码来源:TransactionReceiptDTO.java


示例2: parse

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
private synchronized void parse() {
    if (parsed) return;
    RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);

    this.receipts = new ArrayList<>();
    for (int i = 0; i < paramsList.size(); ++i) {
        RLPList blockRLP = (RLPList) paramsList.get(i);

        List<TransactionReceipt> blockReceipts = new ArrayList<>();
        for (RLPElement txReceipt : blockRLP) {
            RLPList receiptRLP = (RLPList) txReceipt;
            if (receiptRLP.size() != 4) {
                continue;
            }
            TransactionReceipt receipt = new TransactionReceipt(receiptRLP);
            blockReceipts.add(receipt);
        }
        this.receipts.add(blockReceipts);
    }
    this.parsed = true;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:22,代码来源:ReceiptsMessage.java


示例3: onBlock

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
/**
 * For each block we are looking for our transactions and clearing them
 * The actual receiver balance is confirmed upon block arrival
 */
public void onBlock(Block block, List<TransactionReceipt> receipts) {
    int cleared = 0;
    for (Transaction tx : block.getTransactionsList()) {
        ByteArrayWrapper txHash = new ByteArrayWrapper(tx.getHash());
        Transaction ptx = pendingTxs.get(txHash);
        if (ptx != null) {
            logger.info(" - Pending transaction cleared 0x" + Hex.toHexString(tx.getHash()).substring(0, 8) +
                    " in block " + block.getShortDescr());

            pendingTxs.remove(txHash);
            cleared++;
        }
    }
    BigInteger receiverBalance = ethereum.getRepository().getBalance(receiverAddress);
    BigInteger receiverBalancePending = pendingState.getRepository().getBalance(receiverAddress);
    logger.info("" + cleared + " transactions cleared in the block " + block.getShortDescr());
    logger.info("Receiver pending/current balance: " + receiverBalancePending + " / " + receiverBalance +
            " (" + pendingTxs.size() + " pending txs)");
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:24,代码来源:PendingStateSample.java


示例4: sendTxAndWait

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
protected TransactionReceipt sendTxAndWait(byte[] receiveAddress, byte[] data) throws InterruptedException {
    BigInteger nonce = ethereum.getRepository().getNonce(senderAddress);
    Transaction tx = new Transaction(
            ByteUtil.bigIntegerToBytes(nonce),
            ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
            ByteUtil.longToBytesNoLeadZeroes(3_000_000),
            receiveAddress,
            ByteUtil.longToBytesNoLeadZeroes(0),
            data,
            ethereum.getChainIdForNextBlock());
    tx.sign(ECKey.fromPrivate(senderPrivateKey));
    logger.info("<=== Sending transaction: " + tx);
    ethereum.submitTransaction(tx);

    return waitForTx(tx.getHash());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:17,代码来源:CreateContractSample.java


示例5: waitForTx

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
protected TransactionReceipt waitForTx(byte[] txHash) throws InterruptedException {
    ByteArrayWrapper txHashW = new ByteArrayWrapper(txHash);
    txWaiters.put(txHashW, null);
    long startBlock = ethereum.getBlockchain().getBestBlock().getNumber();
    while(true) {
        TransactionReceipt receipt = txWaiters.get(txHashW);
        if (receipt != null) {
            return receipt;
        } else {
            long curBlock = ethereum.getBlockchain().getBestBlock().getNumber();
            if (curBlock > startBlock + 16) {
                throw new RuntimeException("The transaction was not included during last 16 blocks: " + txHashW.toString().substring(0,8));
            } else {
                logger.info("Waiting for block with transaction 0x" + txHashW.toString().substring(0,8) +
                        " included (" + (curBlock - startBlock) + " blocks received so far) ...");
            }
        }
        synchronized (this) {
            wait(20000);
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:23,代码来源:CreateContractSample.java


示例6: sendTxAndWait

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public TransactionReceipt sendTxAndWait(byte[] receiveAddress, byte[] data, byte[]
				senderPrivateKey) throws InterruptedException {
	BigInteger nonce = ethereum.getRepository()
					.getNonce(ECKey.fromPrivate(senderPrivateKey)
									.getAddress());
	Transaction tx = new Transaction(ByteUtil.bigIntegerToBytes(nonce),
					ByteUtil.longToBytesNoLeadZeroes(ethereum.getGasPrice()),
					ByteUtil.longToBytesNoLeadZeroes(3_000_000), receiveAddress,
					ByteUtil.longToBytesNoLeadZeroes(0), data, ethereum.getChainIdForNextBlock());
	tx.sign(ECKey.fromPrivate(senderPrivateKey));
	logger.info("<=== Sending transaction: " + tx);
	ethereum.submitTransaction(tx);
	ethereum.addListener(new EthereumListenerAdapter() {
		@Override
		public void onBlock(Block block, List<TransactionReceipt> receipts) {
			super.onBlock(block, receipts);

			addReceiptIfTxWaiting(receipts);
		}
	});

	return waitForTx(tx.getHash());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:24,代码来源:TransactionManager.java


示例7: deploy

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public byte[] deploy(byte[] senderPrivateKey) {

		assertContractIsCompiled();

		try {
			logger.info("Sending contract to net and waiting for inclusion");
			TransactionReceipt receipt = transactionManager.sendTxAndWait(new byte[0],
							Hex.decode(metadata.bin), senderPrivateKey);

			if (!receipt.isSuccessful()) {
				logger.error("Some troubles creating a contract: " + receipt.getError());
				return senderPrivateKey;
			}

			byte[] contractAddress = receipt.getTransaction()
							.getContractAddress();
			logger.info("Contract created: " + Hex.toHexString(contractAddress));
			return contractAddress;
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return senderPrivateKey;
	}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:24,代码来源:SolidityContractWrapper.java


示例8: onPendingTransactionUpdate

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
private void onPendingTransactionUpdate(TransactionReceipt txReceipt, EthereumListener.PendingTransactionState state, Block block) {
    byte[] txHash = txReceipt.getTransaction().getHash();
    Pair<Long, TransactionResultDTO> removed = remoteTxs.remove(txHash);
    if (state == EthereumListener.PendingTransactionState.DROPPED) {
        if (localTxs.remove(txHash) != null) {
            System.out.println("Dropped due to timeout (matchned: " + (removed != null) + "): " + Hex.toHexString(txHash));
        } else {
            if (remoteTxs.containsKey(txHash)) {
                System.err.println("Dropped but matching: "  + Hex.toHexString(txHash) + ": \n" + txReceipt);
            }
        }
    } else if (state == EthereumListener.PendingTransactionState.NEW_PENDING) {
        System.out.println("Local: " + Hex.toHexString(txHash));
        if (removed == null) {
            localTxs.put(txHash, Triple.of(System.currentTimeMillis(), txReceipt, state));
        } else {
            System.out.println("Tx matched: " + Hex.toHexString(txHash));
        }
    }
    checkUnmatched();
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:22,代码来源:PendingTxMonitor.java


示例9: BlockResult

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public BlockResult(List<Transaction> executedTransactions, List<TransactionReceipt> transactionReceipts,
                   byte[] stateRoot, long gasUsed, BigInteger paidFees) {
    this.executedTransactions = executedTransactions;
    this.transactionReceipts = transactionReceipts;
    this.stateRoot = stateRoot;
    this.gasUsed = gasUsed;
    this.paidFees = paidFees;

    this.receiptsRoot = calculateReceiptsTrie(transactionReceipts);
    this.logsBloom = calculateLogsBloom(transactionReceipts);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:12,代码来源:BlockResult.java


示例10: calculateReceiptsTrie

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
private static byte[] calculateReceiptsTrie(List<TransactionReceipt> receipts) {
    //TODO Fix Trie hash for receipts - doesnt match cpp
    Trie receiptsTrie = new TrieImpl();

    if (receipts.isEmpty()) {
        return HashUtil.EMPTY_TRIE_HASH;
    }

    for (int i = 0; i < receipts.size(); i++) {
        receiptsTrie = receiptsTrie.put(RLP.encodeInt(i), receipts.get(i).getEncoded());
    }

    return receiptsTrie.getHash();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:BlockResult.java


示例11: calculateLogsBloom

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
private static byte[] calculateLogsBloom(List<TransactionReceipt> receipts) {
    Bloom logBloom = new Bloom();

    for (TransactionReceipt receipt : receipts) {
        logBloom.or(receipt.getBloomFilter());
    }

    return logBloom.getData();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:BlockResult.java


示例12: TransactionReceiptDTO

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public  TransactionReceiptDTO(Block block, TransactionInfo txInfo) {

        TransactionReceipt receipt = txInfo.getReceipt();

        status = toJsonHex(txInfo.getReceipt().getStatus());
        blockHash = toJsonHex(txInfo.getBlockHash());
        blockNumber = toJsonHex(block.getNumber());

        RskAddress contractAddress = receipt.getTransaction().getContractAddress();
        if (contractAddress != null) {
            this.contractAddress = toJsonHex(contractAddress.getBytes());
        }

        cumulativeGasUsed = toJsonHex(receipt.getCumulativeGas());
        from = toJsonHex(receipt.getTransaction().getSender().getBytes());
        gasUsed = toJsonHex(receipt.getGasUsed());

        logs = new LogFilterElement[receipt.getLogInfoList().size()];
        for (int i = 0; i < logs.length; i++) {
            LogInfo logInfo = receipt.getLogInfoList().get(i);
            logs[i] = new LogFilterElement(logInfo, block, txInfo.getIndex(),
                    txInfo.getReceipt().getTransaction(), i);
        }

        root = toJsonHex(receipt.getPostTxState());
        to = toJsonHex(receipt.getTransaction().getReceiveAddress().getBytes());
        transactionHash = toJsonHex(receipt.getTransaction().getHash());
        transactionIndex = toJsonHex(txInfo.getIndex());
    }
 
开发者ID:rsksmart,项目名称:rskj,代码行数:30,代码来源:TransactionReceiptDTO.java


示例13: onBlock

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
@Override
public void onBlock(Block block, List<TransactionReceipt> receipts) {
    logger.trace("Start onBlock");

    for (Transaction tx : block.getTransactionsList()) {
        onTransaction(tx);
    }

    logger.trace("End onBlock");
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:11,代码来源:GasPriceTracker.java


示例14: TransactionInfo

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public TransactionInfo(byte[] rlp) {
    ArrayList<RLPElement> params = RLP.decode2(rlp);
    RLPList txInfo = (RLPList) params.get(0);
    RLPList receiptRLP = (RLPList) txInfo.get(0);
    RLPItem blockHashRLP  = (RLPItem) txInfo.get(1);
    RLPItem indexRLP = (RLPItem) txInfo.get(2);

    receipt = new TransactionReceipt(receiptRLP.getRLPData());
    blockHash = blockHashRLP.getRLPData();
    if (indexRLP.getRLPData() == null) {
        index = 0;
    } else {
        index = BigIntegers.fromUnsignedByteArray(indexRLP.getRLPData()).intValue();
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:16,代码来源:TransactionInfo.java


示例15: saveMultiple

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
@Override
public void saveMultiple(byte[] blockHash, List<TransactionReceipt> receipts) {
    int i = 0;
    for (TransactionReceipt receipt : receipts) {
        this.add(blockHash, i++, receipt);
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:ReceiptStoreImpl.java


示例16: listenerTest

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
@Test
public void listenerTest() {
    long time = System.currentTimeMillis();
    Random random = new Random(0);

    Transaction tx1 = Tx.create(0, 0, 0, 0, 0, 0, random);
    Transaction tx2 = Tx.create(0, 0, 0, 1, 0, 0, random);

    Map<String, TxTimestamp> knownTxs = new HashMap<>();
    Map<RskAddress, TxsPerAccount> txsPerAccounts = new HashMap<>();

    random = new Random(0);
    String hash1 = TypeConverter.toJsonHex(BigInteger.valueOf(random.nextLong()).toByteArray());
    String hash2 = TypeConverter.toJsonHex(BigInteger.valueOf(random.nextLong()).toByteArray());

    knownTxs.put(hash1, new TxTimestamp(tx1, time));
    knownTxs.put(hash2, new TxTimestamp(tx1, time));

    TxsPerAccount tpa = new TxsPerAccount();
    tpa.getTransactions().add(tx1);
    tpa.getTransactions().add(tx2);
    txsPerAccounts.put(tx1.getSender(), tpa);

    TransactionReceipt receipt = Mockito.mock(TransactionReceipt.class);
    Mockito.when(receipt.getTransaction()).thenReturn(tx1);
    List<TransactionReceipt> receiptList = new LinkedList<>();
    receiptList.add(receipt);

    TxHandlerImpl txHandler = new TxHandlerImpl(ConfigHelper.CONFIG);
    txHandler.setTxsPerAccounts(txsPerAccounts);
    txHandler.setKnownTxs(knownTxs);

    txHandler.onBlock(null, receiptList);

    Assert.assertEquals(1, txHandler.getKnownTxs().keySet().size());
    Assert.assertEquals(1, txHandler.getTxsPerAccounts().entrySet().iterator().next().getValue().getTransactions().size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:38,代码来源:TxHandlerTest.java


示例17: toString

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
public String toString() {
    parse();
    final StringBuilder sb = new StringBuilder();
    if (receipts.size() < 4) {
        for (List<TransactionReceipt> blockReceipts : receipts)
            sb.append("\n   ").append(blockReceipts.size()).append(" receipts in block");
    } else {
        for (int i = 0; i < 3; i++) {
            sb.append("\n   ").append(receipts.get(i).size()).append(" receipts in block");
        }
        sb.append("\n   ").append("[Skipped ").append(receipts.size() - 3).append(" blocks]");
    }
    return "[" + getCommand().name() + " num:"
            + receipts.size() + " " + sb.toString() + "]";
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:16,代码来源:ReceiptsMessage.java


示例18: onBlock

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
@Override
public void onBlock(Block block, List<TransactionReceipt> receipts) {

    if (startedTxBomb){
        byte[] sender = Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
        long nonce = ethereum.getRepository().getNonce(sender).longValue();;

        for (int i=0; i < 20; ++i){
            sendTx(nonce);
            ++nonce;
            sleep(10);
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:15,代码来源:TransactionBomb.java


示例19: onSyncDone

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
@Override
public void onSyncDone() {
    ethereum.addListener(new EthereumListenerAdapter() {
        // listening here when the PendingState is updated with new transactions
        @Override
        public void onPendingTransactionsReceived(List<Transaction> transactions) {
            for (Transaction tx : transactions) {
                PendingStateSample.this.onPendingTransactionReceived(tx);
            }
        }

        // when block arrives look for our included transactions
        @Override
        public void onBlock(Block block, List<TransactionReceipt> receipts) {
            PendingStateSample.this.onBlock(block, receipts);
        }
    });

    new Thread("PendingStateSampleThread") {
        @Override
        public void run() {
            try {
                sendTransactions();
            } catch (Exception e) {
                logger.error("Error while sending transactions", e);
            }
        }
    }.start();
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:30,代码来源:PendingStateSample.java


示例20: onBlock

import org.ethereum.core.TransactionReceipt; //导入依赖的package包/类
private void onBlock(Block block, List<TransactionReceipt> receipts) {
    for (TransactionReceipt receipt : receipts) {
        ByteArrayWrapper txHashW = new ByteArrayWrapper(receipt.getTransaction().getHash());
        if (txWaiters.containsKey(txHashW)) {
            txWaiters.put(txHashW, receipt);
            synchronized (this) {
                notifyAll();
            }
        }
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:12,代码来源:CreateContractSample.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TkAuth类代码示例发布时间:2022-05-22
下一篇:
Java JapaneseBaseFormFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap