This repository was archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
Perf: Massively improved the performance of the replayMilestones method #1197
Merged
GalRogozinski
merged 22 commits into
iotaledger:dev-localsnapshots
from
iotadevelopment:merge_replaymilestonesrefactor
Nov 29, 2018
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0cea9ad
Feat: added an option to fast forward the ledger state
d7d6f7c
Docs: fixed a typo in the docs
66facac
Perf: Massively improved the performance of the replayMilestones method
0806082
Docs: fixed a typo in the docs
8bdb9a0
Refactor: mocking the SNapshotProvider now
17dda0a
Refactor: fixed an indentation problem
839be17
Refactor: initialized the mocked Snapshots with some "real" values
de804a8
Refactor: renamed test methods to comply with codacy
475ed05
Refactor: refactored the tests and new methods
8816f42
Docs: fixed a typo in the docs
b767f06
Refactor: added some additional unit tests
21c7440
Refactor: refactored the mock classes and the test
4e564dc
Refactor: renamed setup method
17d2e83
Refactor: renamed setup method
83c92d1
Refactor: refactored some code
75df251
Refactor: refactor according to requests
b12e923
Refactor: removed unused import
624bf53
Refactor: refactored some more code
0807f87
Refactor: refactor according to requests
f6ad4bd
Merge branch 'merge_fastforward' of https://github.com/iotadevelopmen…
2ff510c
Merge branch 'dev-localsnapshots' into merge_replaymilestonesrefactor
9756ff6
Refactor: removed unnecessary newline
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import java.nio.file.Paths; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
|
@@ -112,6 +113,10 @@ public void applyStateDiff(SnapshotStateDiff diff) throws SnapshotException { | |
if (balances.computeIfPresent(addressHash, (hash, aLong) -> balance + aLong) == null) { | ||
balances.putIfAbsent(addressHash, balance); | ||
} | ||
|
||
if (balances.get(addressHash) == 0) { | ||
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. 👍 |
||
balances.remove(addressHash); | ||
} | ||
}); | ||
} | ||
|
||
|
@@ -130,6 +135,24 @@ public SnapshotState patchedState(SnapshotStateDiff snapshotStateDiff) { | |
return new SnapshotStateImpl(patchedBalances); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getClass(), balances); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
|
||
if (obj == null || !getClass().equals(obj.getClass())) { | ||
return false; | ||
} | ||
|
||
return Objects.equals(balances, ((SnapshotStateImpl) obj).balances); | ||
} | ||
|
||
GalRogozinski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Returns all addresses that have a negative balance. | ||
* | ||
|
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.
It will also be nice to have a
toString()
here.The
toString()
may only print SnapshotMetadata` toString() to not make it a reasonable size (index, hash, hasSolidEntryPoints). You can also decide to have it print the state, but it will be long.Whatever you think will help with debugging
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.
We can add that in another PR - maybe create an issue to check if all models have these toString methods.