Fix/providers (#590)

* ethers-providers: Fix http Provider request id data race

* ethers-providers: Remove Serialize from JsonRpcClient Response

* Update changelog
This commit is contained in:
Eduard S 2021-11-18 10:59:29 +01:00 committed by GitHub
parent 8eac1997f4
commit 8493451917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,8 @@
- add the missing constructor for `Timelag` middleware via [#568](https://github.com/gakonst/ethers-rs/pull/568)
- re-export error types for `Http` and `Ws` providers in [#570](https://github.com/gakonst/ethers-rs/pull/570)
- add a method on the `Middleware` to broadcast a tx with a series of escalating gas prices via [#566](https://github.com/gakonst/ethers-rs/pull/566)
- Remove unnecessary `Serialize` constraint to `R` (the Response type) in the `request` method of `JsonRpcClient`.
- Fix `http Provider` data race when generating new request `id`s.
### 0.5.3

View File

@ -116,7 +116,7 @@ pub trait JsonRpcClient: Debug + Send + Sync {
async fn request<T, R>(&self, method: &str, params: T) -> Result<R, Self::Error>
where
T: Debug + Serialize + Send + Sync,
R: Serialize + DeserializeOwned;
R: DeserializeOwned;
}
use ethers_core::types::*;

View File

@ -68,8 +68,7 @@ impl JsonRpcClient for Provider {
method: &str,
params: T,
) -> Result<R, ClientError> {
let next_id = self.id.load(Ordering::SeqCst) + 1;
self.id.store(next_id, Ordering::SeqCst);
let next_id = self.id.fetch_add(1, Ordering::SeqCst);
let payload = Request::new(next_id, method, params);