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

Add Concurrency #206

Merged
merged 13 commits into from
May 12, 2022
Merged

Add Concurrency #206

merged 13 commits into from
May 12, 2022

Conversation

llbartekll
Copy link
Contributor

  • add Concurrency to Relayer's subscribe method
  • add Concurrency to Networking Interactor's subscribe method
  • extract Pair Engine(for pair method exclusively) async actor from PairingEngine
  • add Concurrency to client's public methods
  • update sample apps to consume new client's api

closes #168
closes #205

@llbartekll llbartekll self-assigned this May 11, 2022
@llbartekll llbartekll changed the title Adds concurrency Add Concurrency May 11, 2022
…V2 into async-pair

# Conflicts:
#	Sources/WalletConnect/Engine/Common/SessionEngine.swift
#	Sources/WalletConnect/WalletConnectClient.swift
#	Tests/IntegrationTests/ClientTest.swift
#	Tests/WalletConnectTests/SessionEngineTests.swift
@@ -0,0 +1,33 @@

Choose a reason for hiding this comment

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

Are we going to migrate PairingEngines code in here over time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not think so, I would rather split PairingEngine for more classes in the future.
like Controller/ProposeEngine NonController/ProposeEngine`. one class for each protocol method segregated by controller/nonController. Probably we could agree on better naming.

Comment on lines +42 to +52
func testPairMultipleTimesOnSameURIThrows() async {
let uri = WalletConnectURI.stub()
for i in 1...10 {
usleep(100)
if i == 1 {
XCTAssertNoThrow(Task{try await engine.pair(uri)})
} else {
await XCTAssertThrowsErrorAsync(try await engine.pair(uri))
}
}
}

Choose a reason for hiding this comment

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

I think that we could throttle the pair(_:) call (with something like a timer) instead of throwing an error. It's natural for the QR scanner to make multiple calls, the "error" is expected, so it might lead to developer confusion when using the SDK. But this can be done later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think throttle should be implemented on the app side instead of sdk.

try? engine.settle(topic: topicB, proposal: proposal, accounts: [], namespaces: [Namespace.stub()])

usleep(100)

Choose a reason for hiding this comment

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

Why are these usleep() calls needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

settle method has an async Task in it's body and it is not async by itself yet. Assertions are executed synchronously after settle call and concurrently to networkingInteractor.subscribe()
I plan to make settle asyn as well in the future so we can remove usleet()

@sekimondre sekimondre merged commit 6f9397e into develop May 12, 2022
@sekimondre sekimondre deleted the async-pair branch May 12, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants