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

fix(coinjoin): locking improvements #682

Open
wants to merge 1 commit into
base: feat/coinjoin
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DashSyncCurrentCommit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d92d814f3f9a3d40126a9359b578831d8eb97293
3743e9a1f2083656fbcddd4a465b43ce02370aec
5 changes: 1 addition & 4 deletions DashWallet/Sources/Models/CoinJoin/CoinJoinMixingTxSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ final class CoinJoinMixingTxSet: GroupedTransactions, TransactionWrapper {
private let amountLock = NSLock()
private var _amount: Int64 = 0
override var amount: Int64 {
amountLock.lock()
defer { amountLock.unlock() }
Copy link
Member Author

Choose a reason for hiding this comment

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

Read is atomic anyway

return _amount
}

Expand Down Expand Up @@ -90,6 +88,7 @@ final class CoinJoinMixingTxSet: GroupedTransactions, TransactionWrapper {
amountQueue.async { [weak self] in
guard let self = self else { return }
self.amountLock.lock()
defer { self.amountLock.unlock() }

switch type {
case CoinJoinTransactionType_MixingFee,
Expand All @@ -100,8 +99,6 @@ final class CoinJoinMixingTxSet: GroupedTransactions, TransactionWrapper {
default:
break
}

self.amountLock.unlock()
}

return true
Expand Down