本文整理汇总了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;
}
示例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;
}
示例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)");
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}