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

wallet: truncate file after writing #2099

Merged
merged 3 commits into from
Jul 29, 2021
Merged

wallet: truncate file after writing #2099

merged 3 commits into from
Jul 29, 2021

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Jul 29, 2021

If wallet size decreases, we need to remove trailing garbage if it
exists. This can happen when removing account or reading pretty-printed
wallet. It doesn't affect our CLI (we decode only file prefix), but
it is nice to always have a valid JSON file.

Signed-off-by: Evgeniy Stratonikov [email protected]

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who closes the file behind the Wallet, btw?

pkg/wallet/wallet.go Show resolved Hide resolved
@fyrchik
Copy link
Contributor Author

fyrchik commented Jul 29, 2021

@roman-khimov file is closed in wallet.Close via ReadCloser interface.

Signed-off-by: Evgeniy Stratonikov <[email protected]>
@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #2099 (7ca4c36) into master (50d9946) will increase coverage by 0.00%.
The diff coverage is 42.85%.

❗ Current head 7ca4c36 differs from pull request most recent head 283173b. Consider uploading reports for the commit 283173b to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2099   +/-   ##
=======================================
  Coverage   84.17%   84.18%           
=======================================
  Files         288      288           
  Lines       26994    27002    +8     
=======================================
+ Hits        22723    22732    +9     
+ Misses       3034     3032    -2     
- Partials     1237     1238    +1     
Impacted Files Coverage Δ
pkg/wallet/wallet.go 81.00% <42.85%> (-1.61%) ⬇️
pkg/core/native/ledger.go 93.96% <0.00%> (+3.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50d9946...283173b. Read the comment docs.

pkg/wallet/wallet.go Outdated Show resolved Hide resolved
fyrchik added 2 commits July 29, 2021 17:11
If wallet size decreases, we need to remove trailing garbage if it
exists. This can happen when removing account or reading pretty-printed
wallet. It doesn't affect our CLI (we decode only file prefix), but
it is nice to always have a valid JSON file.

Signed-off-by: Evgeniy Stratonikov <[email protected]>
Signed-off-by: Evgeniy Stratonikov <[email protected]>
@roman-khimov roman-khimov merged commit ebbb9df into master Jul 29, 2021
@roman-khimov roman-khimov deleted the wallet-truncate branch July 29, 2021 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants