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


Java Block.getTransactionsList方法代码示例

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


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

示例1: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block, Block parent) {
    if (block == null) {
        logger.warn("BlockTxsFieldsValidationRule - block is null");
        return false;
    }

    List<Transaction> txs = block.getTransactionsList();
    for (Transaction tx : txs) {
        try {
            tx.verify();
        } catch (RuntimeException e) {
            logger.warn("Unable to verify transaction", e);
            return false;
        }
    }

    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:BlockTxsFieldsValidationRule.java

示例2: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block) {
    List<Transaction> txs = block.getTransactionsList();
    if(block.getMinGasPriceAsInteger() == null) {
        logger.warn("Could not retrieve block min gas priceß");
        return false;
    }

    BigInteger blockMgp = block.getMinGasPriceAsInteger();
    if(CollectionUtils.isNotEmpty(block.getTransactionsList())) {
        for (Transaction tx : txs) {
            if (!(tx instanceof RemascTransaction) && tx.getGasPriceAsInteger().compareTo(blockMgp) < 0) {
                logger.warn("Tx gas price is under the Min gas Price of the block");
                panicProcessor.panic("invalidmingasprice", "Tx gas price is under the Min gas Price of the block");
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:TxsMinGasPriceRule.java

示例3: onBlock

import org.ethereum.core.Block; //导入方法依赖的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: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block) {
    List<Transaction> txs = block.getTransactionsList();
    boolean result = CollectionUtils.isNotEmpty(txs) && (txs.get(txs.size()-1) instanceof RemascTransaction);
    if(!result) {
        logger.warn("Remasc tx not found in block");
        panicProcessor.panic("invalidremasctx", "Remasc tx not found in block");
    }
    return result;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:11,代码来源:RemascValidationRule.java

示例5: processBodyRequest

import org.ethereum.core.Block; //导入方法依赖的package包/类
/**
 * processBodyRequest sends the requested block body to a peer if it is available.
 *
 * @param sender the sender of the BodyRequest message.
 * @param requestId the id of the request
 * @param hash   the requested block's hash.
 */
@Override
public void processBodyRequest(@Nonnull final MessageChannel sender, long requestId, @Nonnull final byte[] hash) {
    logger.trace("Processing body request {} {} from {}", requestId, Hex.toHexString(hash).substring(0, 10), sender.getPeerNodeID().toString());
    final Block block = blockSyncService.getBlockFromStoreOrBlockchain(hash);

    if (block == null) {
        // Don't waste time sending an empty response.
        return;
    }

    Message responseMessage = new BodyResponseMessage(requestId, block.getTransactionsList(), block.getUncleList());
    sender.sendMessage(responseMessage);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:NodeBlockProcessor.java

示例6: onBlock

import org.ethereum.core.Block; //导入方法依赖的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

示例7: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block, Block parent) {
    if(block == null || parent == null) {
        logger.warn("BlockTxsValidationRule - block or parent are null");
        return false;
    }

    List<Transaction> txs = block.getTransactionsList();
    if (txs.isEmpty()) {
        return true;
    }

    Repository parentRepo = repository.getSnapshotTo(parent.getStateRoot());

    Map<RskAddress, BigInteger> curNonce = new HashMap<>();

    for (Transaction tx : txs) {
        try {
            tx.verify();
        } catch (RuntimeException e) {
            logger.warn("Unable to verify transaction", e);
            return false;
        }

        RskAddress sender = tx.getSender();
        BigInteger expectedNonce = curNonce.get(sender);
        if (expectedNonce == null) {
            expectedNonce = parentRepo.getNonce(sender.getBytes());
        }
        curNonce.put(sender, expectedNonce.add(ONE));
        BigInteger txNonce = new BigInteger(1, tx.getNonce());

        if (!expectedNonce.equals(txNonce)) {
            logger.warn("Invalid transaction: Tx nonce {} != expected nonce {} (parent nonce: {}): {}",
                    txNonce, expectedNonce, parentRepo.getNonce(sender.getBytes()), tx);

            panicProcessor.panic("invalidtransaction", String.format("Invalid transaction: Tx nonce %s != expected nonce %s (parent nonce: %s): %s",
                    txNonce.toString(), expectedNonce.toString(), parentRepo.getNonce(sender.getBytes()).toString(), Hex.toHexString(tx.getHash())));

            return false;
        }
    }

    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:46,代码来源:BlockTxsValidationRule.java


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