dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Protect finalization state repository against races #872

Closed frolosofsky closed 5 years ago

frolosofsky commented 5 years ago

Add GetLock() to the finalization state repository and acquire them every time finalization state is fetched from the repository.

Although we never faced with such an issue, it's possible that finalization state could be deleted by StateRepository::TrimUntilHeight during it's still in use by another thread.

Fixes #489.

frolosofsky commented 5 years ago

@Gnappuraz @AM5800 @kostyantyn I reworked this PR to have one mutex in the state repository and provide generalized GetLock function.