feat: add logs

This commit is contained in:
Frank.R.Wu 2021-11-18 00:14:03 +08:00
parent aba4d8dad3
commit b3ef7bbe7d

View File

@ -47,7 +47,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
2, 2,
TimeUnit.SECONDS); TimeUnit.SECONDS);
ContractManager.threadPool.submit(() -> { ContractManager.threadPool.submit(() -> {
LOGGER.warn( LOGGER.info(
"[SelfAdaptiveShardingExecutor " + meta.getContractID() + "] starting service..."); "[SelfAdaptiveShardingExecutor " + meta.getContractID() + "] starting service...");
while (running) { while (running) {
LOGGER.info("checking blocks to be executed, latest block=" + LOGGER.info("checking blocks to be executed, latest block=" +
@ -102,16 +102,18 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor {
public void execute(String blockStr) { public void execute(String blockStr) {
Block block = JsonUtil.fromJson(blockStr, Block.class); Block block = JsonUtil.fromJson(blockStr, Block.class);
LOGGER.info(String.format(
"[SelfAdaptiveShardingExecutor %s] receive block %s -> %s, %d transactions, timestamp %d",
meta.getContractID(),
block.hash,
block.prevHash,
block.requests.length,
block.timestamp));
if (!toExecuted.containsKey(block.prevHash) && if (!toExecuted.containsKey(block.prevHash) &&
!executedBlocks.contains(block.hash) && !executedBlocks.contains(block.hash) &&
block.isValid()) { block.isValid()) {
LOGGER.info(String.format(
"[SelfAdaptiveShardingExecutor %s] receive block %s -> %s," +
" %d transactions, timestamp=%d, size=%d",
meta.getContractID(),
block.hash,
block.prevHash,
block.requests.length,
block.timestamp,
blockStr.length()));
toExecuted.put(block.prevHash, block); toExecuted.put(block.prevHash, block);
synchronized (flag) { synchronized (flag) {
flag.notify(); flag.notify();