-
Notifications
You must be signed in to change notification settings - Fork 170
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
i1722-avoid-wallet-rescan-after-init #1723
Open
pragmaxim
wants to merge
21
commits into
master
Choose a base branch
from
i1722-avoid-wallet-rescan-after-init
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b6c7564
i1722-avoid-wallet-rescan-after-init
pragmaxim 075f73c
i1722 hiding wallet phase into wallet state object
pragmaxim 8a0c5e9
i1722 cleanup
pragmaxim e62289a
i1722 reasoning
pragmaxim 1ac27b8
i1722 code formatting
pragmaxim 624e363
i1722 test fix
pragmaxim 827a065
i1722 test fix
pragmaxim 385b199
i1722 test fix
pragmaxim 486d63b
i1722 reverting parallel test execution to false
pragmaxim ea31210
Merge branch 'v4.0.36' into i1722-avoid-wallet-rescan-after-init
pragmaxim a81c82b
i1722 - test fix
pragmaxim 46b57a7
i1722 - better wallet state names
pragmaxim 6a6d6c6
Merge branch 'master' into i1722-avoid-wallet-rescan-after-init
pragmaxim 0d3a9d5
better wallet state naming
pragmaxim 24c49ba
reviewing wallet rescan prevention when wallet created
pragmaxim 641fb2a
Merge branch 'master' into i1722-avoid-wallet-rescan-after-init
pragmaxim e0202af
i1722 fixing compilation error after merging
pragmaxim 35563a5
i1722 more logs
pragmaxim 4a0a221
Merge branch 'v5.0.3' into i1722-avoid-wallet-rescan-after-init
pragmaxim 6a7b4d9
Merge branch 'v5.0.3' of github.com:ergoplatform/ergo into i1722-avoi…
kushti 43a9298
i1722 passing walletPhase ADT instead of boolean
pragmaxim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package org.ergoplatform.nodeView.wallet.persistence | ||
|
||
import java.io.File | ||
|
||
import org.ergoplatform.ErgoBox.BoxId | ||
import org.ergoplatform.nodeView.wallet.IdUtils.{EncodedTokenId, encodedTokenId} | ||
import org.ergoplatform.nodeView.wallet.{WalletTransaction, WalletTransactionSerializer} | ||
|
@@ -15,6 +14,7 @@ import Constants.{PaymentsScanId, ScanId} | |
import org.ergoplatform.ErgoBox | ||
import org.ergoplatform.ErgoLikeContext.Height | ||
import org.ergoplatform.modifiers.history.header.PreGenesisHeader | ||
import org.ergoplatform.nodeView.wallet.ErgoWalletActor.WalletPhase | ||
import scorex.db.LDBVersionedStore | ||
|
||
import scala.util.{Failure, Success, Try} | ||
|
@@ -239,8 +239,9 @@ class WalletRegistry(store: LDBVersionedStore)(ws: WalletSettings) extends Score | |
* @param scanResults - block scan data (outputs created and spent along with corresponding transactions) | ||
* @param blockId - block identifier | ||
* @param blockHeight - block height | ||
* @param walletPhase - whether wallet is uninitialized, created or restored | ||
*/ | ||
def updateOnBlock(scanResults: ScanResults, blockId: ModifierId, blockHeight: Int): Try[Unit] = { | ||
def updateOnBlock(scanResults: ScanResults, blockId: ModifierId, blockHeight: Int, walletPhase: WalletPhase): Try[Unit] = { | ||
|
||
// first, put newly created outputs and related transactions into key-value bag | ||
val bag1 = putBoxes(KeyValuePairsBag.empty, scanResults.outputs) | ||
|
@@ -252,7 +253,7 @@ class WalletRegistry(store: LDBVersionedStore)(ws: WalletSettings) extends Score | |
|
||
// and update wallet digest | ||
updateDigest(bag3) { case WalletDigest(height, wBalance, wTokensSeq) => | ||
if (height + 1 != blockHeight) { | ||
if (height + 1 != blockHeight && walletPhase != WalletPhase.Created) { | ||
log.error(s"Blocks were skipped during wallet scanning, from $height until $blockHeight") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only reason why the walletPhase is being propagated down the |
||
} | ||
val spentWalletBoxes = spentBoxesWithTx.map(_._2).filter(_.scans.contains(PaymentsScanId)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, only
state.getWalletHeight == 0
is not enough as restored wallet has alsostate.getWalletHeight == 0
, that's why theWalletPhase
introduction