Merge pull request #2329 from ManfredKarrer/dao-fix-snapshot-issue

Dao fix snapshot issue
This commit is contained in:
Manfred Karrer 2019-01-29 15:33:15 +01:00 committed by GitHub
commit b087b95826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 23 additions and 73 deletions

View File

@ -186,7 +186,7 @@ public class BsqWalletService extends WalletService implements DaoStateListener
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
if (isWalletReady())
updateBsqWalletTransactions();
}

View File

@ -55,7 +55,6 @@ import bisq.core.dao.governance.proposal.role.RoleProposalFactory;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.DaoStateStorageService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.blockchain.Tx;
import bisq.core.dao.state.model.blockchain.TxOutput;
import bisq.core.dao.state.model.blockchain.TxOutputKey;
@ -188,10 +187,6 @@ public class DaoFacade implements DaoSetupService {
periodService.getCurrentCycle().getPhaseForHeight(blockHeight).ifPresent(phaseProperty::set);
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -275,7 +275,7 @@ public class AssetService implements DaoSetupService, DaoStateListener {
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
int chainHeight = daoStateService.getChainHeight();
bsqFeePerDay = daoStateService.getParamValueAsCoin(Param.ASSET_LISTING_FEE_PER_DAY, chainHeight).value;
minVolumeInBtc = daoStateService.getParamValueAsCoin(Param.ASSET_MIN_VOLUME, chainHeight).value;

View File

@ -78,7 +78,7 @@ public class BallotListPresentation implements BallotListService.BallotListChang
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
onListChanged(ballotListService.getValidatedBallotList());
}

View File

@ -23,7 +23,6 @@ import bisq.core.dao.governance.blindvote.storage.BlindVotePayload;
import bisq.core.dao.governance.blindvote.storage.BlindVoteStorageService;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.network.p2p.P2PService;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
@ -98,10 +97,6 @@ public class BlindVoteListService implements AppendOnlyDataStoreListener, DaoSta
public void onNewBlockHeight(int blockHeight) {
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
fillListFromAppendOnlyDataStore();

View File

@ -35,7 +35,6 @@ import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.MyProposalListService;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.governance.BallotList;
import bisq.core.dao.state.model.governance.CompensationProposal;
import bisq.core.dao.state.model.governance.DaoPhase;
@ -176,10 +175,6 @@ public class MyBlindVoteListService implements PersistedDataHost, DaoStateListen
public void onNewBlockHeight(int blockHeight) {
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
rePublishOnceWellConnected();

View File

@ -161,7 +161,7 @@ public abstract class BondRepository<T extends Bond, R extends BondedAsset> impl
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
update();
}

View File

@ -85,7 +85,7 @@ public class MyBondedReputationRepository implements DaoSetupService {
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
update();
}

View File

@ -22,7 +22,6 @@ import bisq.core.dao.governance.param.Param;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.GenesisTxInfo;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.governance.Cycle;
import bisq.core.dao.state.model.governance.DaoPhase;
@ -83,10 +82,6 @@ public class CycleService implements DaoStateListener, DaoSetupService {
.ifPresent(daoStateService.getCycles()::add);
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -125,7 +125,7 @@ public class ProofOfBurnService implements DaoSetupService, DaoStateListener {
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
updateList();
}

View File

@ -25,7 +25,6 @@ import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.governance.proposal.storage.temp.TempProposalPayload;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.blockchain.Tx;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.dao.state.model.governance.Proposal;
@ -125,10 +124,6 @@ public class MyProposalListService implements PersistedDataHost, DaoStateListene
public void onNewBlockHeight(int blockHeight) {
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
rePublishOnceWellConnected();

View File

@ -96,7 +96,7 @@ public class ProposalListPresentation implements DaoStateListener, MyProposalLis
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
updateLists();
}

View File

@ -158,7 +158,7 @@ public class ProposalService implements HashMapChangedListener, AppendOnlyDataSt
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
int heightForRepublishing = periodService.getFirstBlockOfPhase(daoStateService.getChainHeight(), DaoPhase.Phase.BREAK1);
if (block.getHeight() == heightForRepublishing) {
// We only republish if we are completed with parsing old blocks, otherwise we would republish old

View File

@ -33,7 +33,6 @@ import bisq.core.dao.governance.votereveal.VoteRevealConsensus;
import bisq.core.dao.governance.votereveal.VoteRevealService;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.blockchain.Tx;
import bisq.core.dao.state.model.blockchain.TxOutput;
import bisq.core.dao.state.model.governance.Ballot;
@ -155,10 +154,6 @@ public class VoteResultService implements DaoStateListener, DaoSetupService {
maybeCalculateVoteResult(blockHeight);
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -36,7 +36,6 @@ import bisq.core.dao.node.BsqNode;
import bisq.core.dao.node.BsqNodeProvider;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.blockchain.TxOutput;
import bisq.core.dao.state.model.governance.DaoPhase;
@ -157,10 +156,6 @@ public class VoteRevealService implements DaoStateListener, DaoSetupService {
maybeRevealVotes();
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -22,11 +22,11 @@ import bisq.core.dao.state.model.blockchain.Block;
public interface DaoStateListener {
void onNewBlockHeight(int blockHeight);
void onParseTxsComplete(Block block);
void onParseBlockChainComplete();
// Never used but we still want to provide the event
default void onEmptyBlockAdded(Block block) {
default void onParseTxsCompleteAfterBatchProcessing(Block block) {
}
default void onParseTxsComplete(Block block) {
}
}

View File

@ -200,7 +200,6 @@ public class DaoStateService implements DaoSetupService {
"That might happen in edge cases at reorgs.");
} else {
daoState.getBlocks().add(block);
daoStateListeners.forEach(l -> l.onEmptyBlockAdded(block));
log.info("New Block added at blockHeight " + block.getHeight());
}
@ -208,9 +207,12 @@ public class DaoStateService implements DaoSetupService {
// Third we get the onParseBlockComplete called after all rawTxs of blocks have been parsed
public void onParseBlockComplete(Block block) {
// We don't call it during batch parsing as that decreased performance a lot.
// With calling at each block we got about 50 seconds for 4000 blocks, without about 4 seconds.
// We use 2 different handlers as we don't want to update domain listeners during batch processing of all
// blocks as that cause performance issues. In earlier versions when we updated at each block it took
// 50 sec. for 4000 blocks, after that change it was about 4 sec.
if (parseBlockChainComplete)
daoStateListeners.forEach(l -> l.onParseTxsCompleteAfterBatchProcessing(block));
else
daoStateListeners.forEach(l -> l.onParseTxsComplete(block));
}

View File

@ -38,7 +38,7 @@ import lombok.extern.slf4j.Slf4j;
*/
@Slf4j
public class DaoStateSnapshotService implements DaoStateListener {
private static final int SNAPSHOT_GRID = 10;
private static final int SNAPSHOT_GRID = 20;
private final DaoStateService daoStateService;
private final GenesisTxInfo genesisTxInfo;
@ -74,6 +74,8 @@ public class DaoStateSnapshotService implements DaoStateListener {
public void onNewBlockHeight(int blockHeight) {
}
// We listen to each ParseTxsComplete event even if the batch processing of all blocks at startup is not completed
// as we need to write snapshots during that batch processing.
@Override
public void onParseTxsComplete(Block block) {
int chainHeight = block.getHeight();

View File

@ -22,7 +22,6 @@ import bisq.desktop.util.Layout;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.locale.Res;
@ -96,10 +95,6 @@ public class PhasesView implements DaoStateListener {
applyData(height);
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -25,7 +25,6 @@ import bisq.desktop.util.Layout;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.locale.Res;
import bisq.core.util.BSFormatter;
@ -111,10 +110,6 @@ public class GovernanceDashboardView extends ActivatableView<GridPane, Void> imp
applyData(height);
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -38,7 +38,6 @@ import bisq.core.dao.governance.proposal.ProposalWithTransaction;
import bisq.core.dao.governance.proposal.TxException;
import bisq.core.dao.governance.proposal.param.ChangeParamValidator;
import bisq.core.dao.state.DaoStateListener;
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.dao.state.model.governance.DaoPhase;
import bisq.core.dao.state.model.governance.Proposal;
import bisq.core.dao.state.model.governance.Role;
@ -188,10 +187,6 @@ public class MakeProposalView extends ActivatableView<GridPane, Void> implements
proposalTypeComboBox.getSelectionModel().clearSelection();
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -270,7 +270,7 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
updateViews();
}

View File

@ -184,10 +184,6 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
fillCycleList();
}
@Override
public void onParseTxsComplete(Block block) {
}
@Override
public void onParseBlockChainComplete() {
}

View File

@ -178,7 +178,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
updateWithBsqBlockChainData();
}

View File

@ -218,7 +218,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
}
@Override
public void onParseTxsComplete(Block block) {
public void onParseTxsCompleteAfterBatchProcessing(Block block) {
onUpdateAnyChainHeight();
}