use of org.aion.zero.types.IAionBlock in project aion by aionnetwork.
the class FltrLg method onBlock.
// -------------------------------------------------------------------------------
@Override
public boolean onBlock(IBlockSummary bs) {
List<AionTxReceipt> receipts = ((AionBlockSummary) bs).getReceipts();
IBlock blk = bs.getBlock();
if (matchBloom(new Bloom(((IAionBlock) blk).getLogBloom()))) {
int txIndex = 0;
for (AionTxReceipt receipt : receipts) {
ITransaction tx = receipt.getTransaction();
if (matchesContractAddress(tx.getTo().toBytes())) {
if (matchBloom(receipt.getBloomFilter())) {
int logIndex = 0;
for (Log logInfo : receipt.getLogInfoList()) {
if (matchBloom(logInfo.getBloom()) && matchesExactly(logInfo)) {
add(new EvtLg(new TxRecptLg(logInfo, blk, txIndex, receipt.getTransaction(), logIndex, true)));
}
logIndex++;
}
}
}
txIndex++;
}
}
return true;
}
use of org.aion.zero.types.IAionBlock in project aion by aionnetwork.
the class EquihashMiner method mine.
/**
* Keeps mining until the thread is interrupted
*/
protected void mine() {
IAionBlock block;
byte[] nonce;
while (!Thread.currentThread().isInterrupted()) {
if ((block = miningBlock) == null) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
break;
}
} else {
// A new array must be created each loop
// If reference is reused the array contents may be changed
// before block sealed causing validation to fail
nonce = new byte[32];
ThreadLocalRandom.current().nextBytes(nonce);
Solution s = miner.mine(block, nonce);
if (s != null) {
IEvent ev = new EventConsensus(EventConsensus.CALLBACK.ON_SOLUTION);
ev.setFuncArgs(Collections.singletonList(s));
evtMgr.newEvent(ev);
}
}
}
}
use of org.aion.zero.types.IAionBlock in project aion by aionnetwork.
the class AionBlockStore method getListHashesEndWith.
@Override
public List<byte[]> getListHashesEndWith(byte[] hash, long number) {
List<AionBlock> blocks = getListBlocksEndWith(hash, number);
List<byte[]> hashes = new ArrayList<>(blocks.size());
for (IAionBlock b : blocks) {
hashes.add(b.getHash());
}
return hashes;
}
Aggregations