Skip to content

Commit

Permalink
[fix] Fix BlockDao getLastBlockWithUD (exclude 'current' block)
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Sep 4, 2020
1 parent 573c4bd commit ed5dfb5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public interface BlockDao extends Bean, TypeDao<BlockDao> {

String TYPE = "block";
String CURRENT_BLOCK_ID = "current";


void create(BlockchainBlock block, boolean wait);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ public BytesReference getBlockByIdAsBytes(String currencyName, String id) {
public long[] getBlockNumberWithUd(String currencyName) {
return getBlockNumbersFromQuery(currencyName,
QueryBuilders.boolQuery()
.filter(QueryBuilders.existsQuery(BlockchainBlock.PROPERTY_DIVIDEND)));
.filter(QueryBuilders.existsQuery(BlockchainBlock.PROPERTY_DIVIDEND))
);
}

@Override
Expand Down Expand Up @@ -576,6 +577,8 @@ protected long[] getBlockNumbersFromQuery(String currencyName, QueryBuilder quer
offset += size;
} while (offset < total);

return ids.stream().mapToLong(Long::parseLong).sorted().toArray();
return ids.stream()
.filter(id -> !BlockDao.CURRENT_BLOCK_ID.equals(id))
.mapToLong(Long::parseLong).sorted().toArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@
*/
public class BlockchainService extends AbstractService {

private static final BlockchainBlock DEFAULT_BLOCK = KnownBlocks.getFirstBlock(KnownCurrencies.G1);
public static final String BLOCK_TYPE = BlockDao.TYPE;
public static final String CURRENT_BLOCK_ID = "current";
public static final String CURRENT_BLOCK_ID = BlockDao.CURRENT_BLOCK_ID;

private static final int SYNC_MISSING_BLOCK_MAX_RETRY = 5;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cesium-plus-pod-core.config=
duniter.p2p.error.noRemoteUrl=The cluster address can not be published on the network. /\!\\ Fill in the options [cluster.remote.xxx] in the configuration (recommended).
duniter4j.blockIndexerService.detectFork.invalidBlock=[%s] [%s] Detecting fork\: block \#%s -> new hash [%s]
duniter4j.blockIndexerService.detectFork.invalidBlockchain=[%s] [%s] Peer has another blockchain (no common blocks \!). Skipping block \#%s - hash [%s].
duniter4j.blockIndexerService.detectFork.invalidBlock=[%s] [%s] Detecting fork\: block \#%s -> new {hash: %s}
duniter4j.blockIndexerService.detectFork.invalidBlockchain=[%s] [%s] Peer has another blockchain (no common blocks \!). Skipping block \#%s - {hash: %s}
duniter4j.blockIndexerService.detectFork.remoteBlockNotFound=[%s] [%s] Unable to get block \#%s from peer\: %s
duniter4j.blockIndexerService.detectFork.resync=[%s] [%s] Rollback index from block \#%s, and resync
duniter4j.blockIndexerService.indexBlock=[%s] [%s] Indexing block \#%s - hash [%s]
duniter4j.blockIndexerService.indexBlock=[%s] [%s] Indexing block \#%s {hash: %s}
duniter4j.blockIndexerService.indexBlocksRange.remoteParametersError=
duniter4j.blockIndexerService.indexBlocksRange.succeed=
duniter4j.blockIndexerService.indexBlocksRange.task=
Expand All @@ -13,7 +13,7 @@ duniter4j.blockIndexerService.indexLastBlocks.otherPeers.task=Indexing missing b
duniter4j.blockIndexerService.indexLastBlocks.progress=[%s] [%s] Indexing block \#%s / %s (%s%%)...
duniter4j.blockIndexerService.indexLastBlocks.remoteParametersError=[%s] Error when calling [/blockchain/parameters]\: %s
duniter4j.blockIndexerService.indexLastBlocks.stopped=[%s] [%s] Indexing last block - stopped
duniter4j.blockIndexerService.indexLastBlocks.succeed=[%s] [%s] All blocks indexed [%s ms]
duniter4j.blockIndexerService.indexLastBlocks.succeed=[%s] [%s] All blocks indexed in %s ms
duniter4j.blockIndexerService.indexLastBlocks.task=[%s] [%s] Indexing last blocks...
duniter4j.config.option.basedir.description=
duniter4j.config.option.data.directory.description=
Expand All @@ -40,8 +40,8 @@ duniter4j.config.option.version.description=
duniter4j.config.parse.error=
duniter4j.es.networkService.indexPeer=[%s] Indexing peer [%s]...
duniter4j.es.networkService.indexPeers.progress=[%s] [%s] Indexing peers (%s%%)...
duniter4j.es.networkService.indexPeers.remoteParametersError=[%s] Error when calling [/blockchain/parameters]\: %s
duniter4j.es.networkService.indexPeers.succeed=[%s] [%s] All peers indexed\: found [%s] in [%s ms]
duniter4j.es.networkService.indexPeers.remoteParametersError=[%s] Error when calling {/blockchain/parameters}\: %s
duniter4j.es.networkService.indexPeers.succeed=[%s] [%s] All peers indexed\: %s found in %s ms
duniter4j.es.networkService.indexPeers.task=[%s] [%s] Indexing peers...
duniter4j.executor.task.waitingExecution=
duniter4j.job.stopped=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ duniter4j.blockIndexerService.detectFork.invalidBlock=[%s] [%s] Detecting fork\:
duniter4j.blockIndexerService.detectFork.invalidBlockchain=[%s] [%s] Peer has another blockchain (no common blocks \!). Skipping block \#%s - hash [%s].
duniter4j.blockIndexerService.detectFork.remoteBlockNotFound=[%s] [%s] Unable to get block \#%s from peer\: %s
duniter4j.blockIndexerService.detectFork.resync=[%s] [%s] Rollback index from block \#%s, and resync
duniter4j.blockIndexerService.indexBlock=[%s] [%s] Indexing block \#%s - hash [%s]
duniter4j.blockIndexerService.indexBlock=[%s] [%s] Indexing block \#%s - {hash: %s}
duniter4j.blockIndexerService.indexBlocksRange.invalidBlockchain=[%s] [%s] Peer has another blockchain (no common blocks \!). Skipping blocks range indexation.
duniter4j.blockIndexerService.indexBlocksRange.remoteParametersError=[%s] Error when calling [/blockchain/parameters]\: %s
duniter4j.blockIndexerService.indexBlocksRange.stopped=[%s] [%s] Indexing blocks from range - stopped
Expand All @@ -15,7 +15,7 @@ duniter4j.blockIndexerService.indexLastBlocks.otherPeers.task=Indexing missing b
duniter4j.blockIndexerService.indexLastBlocks.progress=[%s] [%s] Indexing block \#%s / %s (%s%%)...
duniter4j.blockIndexerService.indexLastBlocks.remoteParametersError=[%s] Error when calling [/blockchain/parameters]\: %s
duniter4j.blockIndexerService.indexLastBlocks.stopped=[%s] [%s] Indexing last block - stopped
duniter4j.blockIndexerService.indexLastBlocks.succeed=[%s] [%s] All blocks indexed [%s ms]
duniter4j.blockIndexerService.indexLastBlocks.succeed=[%s] [%s] All blocks indexed in %s ms
duniter4j.blockIndexerService.indexLastBlocks.task=[%s] [%s] Indexing last blocks...
duniter4j.config.option.basedir.description=
duniter4j.config.option.data.directory.description=
Expand All @@ -42,8 +42,8 @@ duniter4j.config.option.version.description=
duniter4j.config.parse.error=
duniter4j.es.networkService.indexPeer=[%s] Indexing peer [%s]...
duniter4j.es.networkService.indexPeers.progress=[%s] [%s] Indexing peers (%s%%)...
duniter4j.es.networkService.indexPeers.remoteParametersError=[%s] Error when calling [/blockchain/parameters]\: %s
duniter4j.es.networkService.indexPeers.succeed=[%s] [%s] All peers indexed\: found [%s] in [%s ms]
duniter4j.es.networkService.indexPeers.remoteParametersError=[%s] Error when calling {/blockchain/parameters}\: %s
duniter4j.es.networkService.indexPeers.succeed=[%s] [%s] All peers indexed\: %s found in %s ms
duniter4j.es.networkService.indexPeers.task=[%s] [%s] Indexing peers...
duniter4j.executor.task.waitingExecution=
duniter4j.job.stopped=
Expand Down

0 comments on commit ed5dfb5

Please sign in to comment.