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

Access blocks and transactions of the chain with lock #583

Merged
merged 4 commits into from Oct 15, 2019

Conversation

@earlbread
Copy link
Member

earlbread commented Oct 15, 2019

#409 occurs when a task tries to read a block or transaction from BlockChain<T>.Blocks or BlockChain<T>.Transactions while another task is writing it. This fixes #409 by changing blocks and transactions in the BlockChain<T> so that it cannot be accessed without the lock from the outside of the chain.

@earlbread earlbread added the bug label Oct 15, 2019
@earlbread earlbread requested review from dahlia, longfin, limebell and moreal Oct 15, 2019
@earlbread earlbread self-assigned this Oct 15, 2019
/// </param>
/// <exception cref="KeyNotFoundException">Thrown when there is no
/// <see cref="Transaction{T}"/> with a given <paramref name="txId"/>.</exception>
public Transaction<T> this[TxId txId]

This comment has been minimized.

Copy link
@dahlia

dahlia Oct 15, 2019

Member

Instead of overloading this and making indexer able to return two distinct types, how about declare a method like GetTransaction(TxId)?

This comment has been minimized.

Copy link
@earlbread

earlbread Oct 15, 2019

Author Member

That would be better. Fixed.

@codecov

This comment has been minimized.

Copy link

codecov bot commented Oct 15, 2019

Codecov Report

Merging #583 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #583      +/-   ##
==========================================
- Coverage   90.74%   90.72%   -0.02%     
==========================================
  Files         202      202              
  Lines       15514    15542      +28     
==========================================
+ Hits        14078    14101      +23     
- Misses       1144     1149       +5     
  Partials      292      292
Impacted Files Coverage Δ
Libplanet/Net/Swarm.cs 84.78% <100%> (ø) ⬆️
Libplanet.Tests/Net/SwarmTest.cs 98.95% <100%> (ø) ⬆️
Libplanet.Tests/Blockchain/BlockChainTest.cs 98.68% <100%> (-0.01%) ⬇️
Libplanet/Blockchain/BlockChain.cs 94.5% <100%> (+0.25%) ⬆️
Libplanet/Store/BaseIndex.cs 20.75% <0%> (-9.44%) ⬇️
@earlbread earlbread force-pushed the earlbread:fix-blocks branch from 99daee7 to 65dd02b Oct 15, 2019
@earlbread earlbread requested a review from dahlia Oct 15, 2019
@earlbread earlbread force-pushed the earlbread:fix-blocks branch from 65dd02b to c564b61 Oct 15, 2019
@earlbread earlbread requested a review from limebell Oct 15, 2019
@longfin

This comment has been minimized.

Copy link
Member

longfin commented Oct 15, 2019

I think that we also need to add a mutex for block synchronization to LiteDBStore. (even in other PR)

Co-Authored-By: Hong Minhee <hong.minhee@gmail.com>
@earlbread earlbread dismissed stale reviews from dahlia, longfin, and moreal via a0a0ec8 Oct 15, 2019
@earlbread earlbread requested review from dahlia, longfin and moreal Oct 15, 2019
@dahlia
dahlia approved these changes Oct 15, 2019
@earlbread earlbread merged commit 24a2e5a into planetarium:master Oct 15, 2019
20 checks passed
20 checks passed
dist
Details
dist
Details
docs
Details
docs
Details
WIP Ready for review
Details
changelog This contains self-describing changelog.
Details
codecov/patch 100% of diff hit (target 90.74%)
Details
codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +9.25% compared to 953c36c
Details
license/cla Contributor License Agreement is signed.
Details
planetarium.libplanet Build #20191015.20 succeeded
Details
planetarium.libplanet (Linux_Mono) Linux_Mono succeeded
Details
planetarium.libplanet (Linux_NETCore) Linux_NETCore succeeded
Details
planetarium.libplanet (Windows_Mono) Windows_Mono succeeded
Details
planetarium.libplanet (Windows_NETCore) Windows_NETCore succeeded
Details
planetarium.libplanet (Windows_NETCore_Benchmark) Windows_NETCore_Benchmark succeeded
Details
planetarium.libplanet (Windows_NETCore_coverage) Windows_NETCore_coverage succeeded
Details
planetarium.libplanet (Windows_NETFramework) Windows_NETFramework succeeded
Details
planetarium.libplanet (macOS_Mono) macOS_Mono succeeded
Details
planetarium.libplanet (macOS_NETCore) macOS_NETCore succeeded
Details
planetarium.libplanet (macOS_Unity) macOS_Unity succeeded
Details
@earlbread earlbread deleted the earlbread:fix-blocks branch Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.