use of org.aion.mcf.core.ImportResult in project aion by aionnetwork.
the class TaskImportBlocks method run.
@Override
public void run() {
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
while (start.get()) {
BlocksWrapper bw;
try {
bw = importedBlocks.take();
} catch (InterruptedException ex) {
return;
}
List<AionBlock> batch = bw.getBlocks();
for (AionBlock b : batch) {
if (importedBlockHashes.containsKey(ByteArrayWrapper.wrap(b.getHash()))) {
continue;
}
long t1 = System.currentTimeMillis();
ImportResult importResult = this.chain.tryToConnect(b);
long t2 = System.currentTimeMillis();
log.info("<import-status: node = {}, number = {}, txs = {}, result = {}, time elapsed = {} ms>", bw.getDisplayId(), b.getNumber(), b.getTransactionsList().size(), importResult, t2 - t1);
switch(importResult) {
case IMPORTED_BEST:
importedBlockHashes.put(ByteArrayWrapper.wrap(b.getHash()), null);
break;
case IMPORTED_NOT_BEST:
importedBlockHashes.put(ByteArrayWrapper.wrap(b.getHash()), null);
break;
case EXIST:
importedBlockHashes.put(ByteArrayWrapper.wrap(b.getHash()), null);
break;
case NO_PARENT:
break;
case INVALID_BLOCK:
break;
default:
break;
}
}
this.statis.update(this.chain.getBestBlock().getNumber());
}
}
Aggregations