Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various optimizations #3112

Merged
merged 7 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ public ChangeParamValidator(DaoStateService daoStateService, PeriodService perio
public void validateDataFields(Proposal proposal) throws ProposalValidationException {
try {
super.validateDataFields(proposal);
ChangeParamProposal changeParamProposal = (ChangeParamProposal) proposal;
validateParamValue(changeParamProposal.getParam(), changeParamProposal.getParamValue(), getBlockHeight(proposal));
checkArgument(changeParamProposal.getParamValue().length() <= 200, "ParamValue must not exceed 200 chars");

// Only once parsing is complete we can check for param changes
if (daoStateService.isParseBlockChainComplete()) {
ChangeParamProposal changeParamProposal = (ChangeParamProposal) proposal;
validateParamValue(changeParamProposal.getParam(), changeParamProposal.getParamValue(), getBlockHeight(proposal));
checkArgument(changeParamProposal.getParamValue().length() <= 200, "ParamValue must not exceed 200 chars");
}
} catch (ProposalValidationException e) {
throw e;
} catch (Throwable throwable) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/dao/node/lite/LiteNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void onRequestedBlocksReceived(List<RawBlock> blockList, Runnable onPars

runDelayedBatchProcessing(new ArrayList<>(blockList),
() -> {
log.info("Parsing {} blocks took {} seconds.", blockList.size(), (System.currentTimeMillis() - ts) / 1000d);
log.debug("Parsing {} blocks took {} seconds.", blockList.size(), (System.currentTimeMillis() - ts) / 1000d);
if (daoStateService.getChainHeight() < bsqWalletService.getBestChainHeight()) {
liteNodeNetworkService.requestBlocks(getStartBlockHeight());
} else {
Expand Down Expand Up @@ -229,7 +229,7 @@ private void runDelayedBatchProcessing(List<RawBlock> blocks, Runnable resultHan
// We received a new block
private void onNewBlockReceived(RawBlock block) {
int blockHeight = block.getHeight();
log.info("onNewBlockReceived: block at height {}, hash={}", blockHeight, block.getHash());
log.debug("onNewBlockReceived: block at height {}, hash={}", blockHeight, block.getHash());

// We only update chainTipHeight if we get a newer block
if (blockHeight > chainTipHeight)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void onMessage(NetworkEnvelope networkEnvelope, Connection connection) {
List<String> txIds = newBlockBroadcastMessage.getBlock().getRawTxs().stream().map(BaseTx::getId).collect(Collectors.toList());
String extBlockId = newBlockBroadcastMessage.getBlock().getHash() + ":" + txIds;
if (!receivedBlocks.contains(extBlockId)) {
log.info("We received a new message from peer {} and broadcast it to our peers. extBlockId={}",
log.debug("We received a new message from peer {} and broadcast it to our peers. extBlockId={}",
connection.getPeersNodeAddressOptional(), extBlockId);
receivedBlocks.add(extBlockId);
broadcaster.broadcast(newBlockBroadcastMessage, networkNode.getNodeAddress(), null, false);
Expand Down Expand Up @@ -259,7 +259,7 @@ private void requestBlocks(NodeAddress peersNodeAddress, int startBlockHeight) {
new RequestBlocksHandler.Listener() {
@Override
public void onComplete(GetBlocksResponse getBlocksResponse) {
log.info("requestBlocksHandler of outbound connection complete. nodeAddress={}",
log.debug("requestBlocksHandler of outbound connection complete. nodeAddress={}",
peersNodeAddress);
stopRetryTimer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void maybeCreateSnapshot(Block block) {
LinkedList<DaoStateHash> clonedDaoStateHashChain = new LinkedList<>(daoStateHashChainSnapshotCandidate);
daoStateStorageService.persist(clonedDaoState, clonedDaoStateHashChain);

log.info("Saved snapshotCandidate with height {} to Disc at height {} took {} ms",
log.debug("Saved snapshotCandidate with height {} to Disc at height {} took {} ms",
daoStateSnapshotCandidate.getChainHeight(), chainHeight, System.currentTimeMillis() - ts);
}

Expand All @@ -107,7 +107,7 @@ public void maybeCreateSnapshot(Block block) {
daoStateSnapshotCandidate = daoStateService.getClone();
daoStateHashChainSnapshotCandidate = new LinkedList<>(daoStateMonitoringService.getDaoStateHashChain());

log.info("Cloned new snapshotCandidate at height {} took {} ms", chainHeight, System.currentTimeMillis() - ts);
log.debug("Cloned new snapshotCandidate at height {} took {} ms", chainHeight, System.currentTimeMillis() - ts);
}
}

Expand All @@ -119,7 +119,7 @@ public void applySnapshot(boolean fromReorg) {
int chainHeightOfPersisted = persistedBsqState.getChainHeight();
if (!blocks.isEmpty()) {
int heightOfLastBlock = blocks.getLast().getHeight();
log.info("applySnapshot from persistedBsqState daoState with height of last block {}", heightOfLastBlock);
log.debug("applySnapshot from persistedBsqState daoState with height of last block {}", heightOfLastBlock);
if (isValidHeight(heightOfLastBlock)) {
if (chainHeightOfLastApplySnapshot != chainHeightOfPersisted) {
chainHeightOfLastApplySnapshot = chainHeightOfPersisted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ public String getProviderNodeAddress() {

private void request(boolean repeatRequests) {
if (requestTs == 0)
log.info("request from provider {}",
log.debug("request from provider {}",
providersRepository.getBaseUrl());
else
log.info("request from provider {} {} sec. after last request",
log.debug("request from provider {} {} sec. after last request",
providersRepository.getBaseUrl(),
(System.currentTimeMillis() - requestTs) / 1000d);

Expand All @@ -158,12 +158,12 @@ private void request(boolean repeatRequests) {
if (success) {
final MarketPrice marketPrice = cache.get(currencyCode);
if (marketPrice != null)
log.info("Received new {} from provider {} after {} sec.",
log.debug("Received new {} from provider {} after {} sec.",
marketPrice,
baseUrlOfRespondingProvider,
(System.currentTimeMillis() - requestTs) / 1000d);
else
log.info("Received new data from provider {} after {} sec. " +
log.debug("Received new data from provider {} after {} sec. " +
"Requested market price for currency {} was not provided. " +
"That is expected if currency is not listed at provider.",
baseUrlOfRespondingProvider,
Expand All @@ -182,7 +182,7 @@ private void request(boolean repeatRequests) {
baseUrlOfCurrentRequest, baseUrlOfFaultyRequest);
retryWithNewProvider();
} else {
log.info("We received an error from an earlier request. We have started a new request already so we ignore that error. " +
log.debug("We received an error from an earlier request. We have started a new request already so we ignore that error. " +
"baseUrlOfCurrentRequest={}, baseUrlOfFaultyRequest={}",
baseUrlOfCurrentRequest, baseUrlOfFaultyRequest);
}
Expand Down Expand Up @@ -360,10 +360,10 @@ private boolean applyPriceToConsumer() {
}
} else {
if (baseUrlOfRespondingProvider == null)
log.info("Market price for currency " + currencyCode + " was not delivered by provider " +
log.debug("Market price for currency " + currencyCode + " was not delivered by provider " +
baseUrl + ". That is expected at startup.");
else
log.info("Market price for currency " + currencyCode + " is not provided by the provider " +
log.debug("Market price for currency " + currencyCode + " is not provided by the provider " +
baseUrl + ". That is expected for currencies not listed at providers.");
result = true;
}
Expand All @@ -372,7 +372,7 @@ private boolean applyPriceToConsumer() {
". priceProvider=" + baseUrl + ". Exception=" + t;
}
} else {
log.info("We don't have a price for currency " + currencyCode + ". priceProvider=" + baseUrl +
log.debug("We don't have a price for currency " + currencyCode + ". priceProvider=" + baseUrl +
". That is expected for currencies not listed at providers.");
result = true;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,7 @@ list.currency.editList=Edit currency list

table.placeholder.noItems=Currently there are no {0} available
table.placeholder.noData=Currently there is no data available
table.placeholder.processingData=Processing data...


peerInfoIcon.tooltip.tradePeer=Trading peer's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,24 @@
package bisq.desktop.main.dao.governance.result;

import bisq.core.dao.governance.proposal.IssuanceProposal;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.governance.EvaluatedProposal;
import bisq.core.locale.Res;
import bisq.core.util.BsqFormatter;

import org.bitcoinj.core.Coin;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import lombok.Getter;

public class CycleListItem {
private final DaoStateService daoStateService;
private final BsqFormatter bsqFormatter;
@Getter
private ResultsOfCycle resultsOfCycle;

CycleListItem(ResultsOfCycle resultsOfCycle,
DaoStateService daoStateService,
BsqFormatter bsqFormatter) {
this.resultsOfCycle = resultsOfCycle;
this.daoStateService = daoStateService;
this.bsqFormatter = bsqFormatter;
}

Expand All @@ -67,15 +61,7 @@ public String getNumVotesAsString() {
}

public String getMeritAndStake() {
//TODO move to domain
Map<String, Long> map = new HashMap<>();
resultsOfCycle.getDecryptedVotesForCycle()
.forEach(decryptedVote -> {
decryptedVote.getBallotList().stream().forEach(ballot -> {
map.putIfAbsent(decryptedVote.getBlindVoteTxId(), decryptedVote.getStake() + decryptedVote.getMerit(daoStateService));
});
});
return bsqFormatter.formatCoinWithCode(Coin.valueOf(map.values().stream().mapToLong(e -> e).sum()));
return bsqFormatter.formatCoinWithCode(Coin.valueOf(resultsOfCycle.getMeritAndStake()));
}

public String getIssuance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ResultsOfCycle {
private final int numVotes;
private final int numAcceptedVotes;
private final int numRejectedVotes;
private final long meritAndStake;
private final DaoStateService daoStateService;
private long cycleStartTime;

Expand All @@ -54,6 +55,7 @@ class ResultsOfCycle {
List<Proposal> proposals,
List<EvaluatedProposal> evaluatedProposals,
List<DecryptedBallotsWithMerits> decryptedVotesForCycle,
long meritAndStake,
DaoStateService daoStateService) {
this.cycle = cycle;
this.cycleIndex = cycleIndex;
Expand All @@ -71,6 +73,7 @@ class ResultsOfCycle {
numRejectedVotes = evaluatedProposals.stream()
.mapToInt(e -> e.getProposalVoteResult().getNumRejectedVotes())
.sum();
this.meritAndStake = meritAndStake;
this.daoStateService = daoStateService;
}

Expand Down
Loading