Skip to content

Commit

Permalink
add async concurrent queue
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Nov 17, 2020
1 parent 6888511 commit 9732109
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 70 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ client.boc.parse_message(payload) { (response) in
}
}
```
## Errors

```swift
client.crypto.factorize(TSDKParamsOfFactorize(composite: "17ED48941A08F981")) { (response) in
if let error = response.error {
print(error.data.toJSON())
print(error.code)
}
}
```

## Tests
### If you use Xcode for Test
Expand All @@ -86,6 +95,8 @@ useCustomWorkingDirectory = "YES"
customWorkingDirectory = "/path_to_ton_sdk"


Tests

1. inside root directory of ton-client-swift create .env.debug file with

```
Expand Down
14 changes: 7 additions & 7 deletions Sources/TonClientSwift/Abi/Abi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfEncodeMessageBody, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -34,7 +34,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfEncodeMessage, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -45,7 +45,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfAttachSignatureToMessageBody, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -56,7 +56,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfAttachSignature, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -67,7 +67,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKDecodedMessageBody, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -78,7 +78,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKDecodedMessageBody, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -89,7 +89,7 @@ public final class TSDKAbiModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfEncodeAccount, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}
}
12 changes: 6 additions & 6 deletions Sources/TonClientSwift/Boc/Boc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfParse, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -34,7 +34,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfParse, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -45,7 +45,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfParse, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -56,7 +56,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfParse, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -67,7 +67,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfGetBlockchainConfig, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}

Expand All @@ -78,7 +78,7 @@ public final class TSDKBocModule {
binding.requestLibraryAsync(methodName(module, method), payload, { (requestId, params, responseType, finished) in
var response: TSDKBindingResponse<TSDKResultOfGetBocHash, TSDKClientError, TSDKDefault> = .init()
response.update(requestId, params, responseType, finished)
handler(response)
BindingStore.responseQueue.async { handler(response) }
})
}
}
Loading

0 comments on commit 9732109

Please sign in to comment.