Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d543450

Browse files
committedMar 2, 2020
remove format! in async workaround (see github.com/rust-lang/rust/issues/64960)
1 parent 1940560 commit d543450

File tree

1 file changed

+15
-59
lines changed

1 file changed

+15
-59
lines changed
 

‎core/src/light_protocol/query_service.rs

+15-59
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,9 @@ impl QueryService {
116116
) -> Result<StateRoot, String> {
117117
trace!("retrieve_state_root epoch = {}", epoch);
118118

119-
// We cannot await in scope that contains call to format!
120-
// This is likely to be fixed in a future compiler version.
121-
// See: https://github.com/rust-lang/rust/issues/64960
122-
let msg =
123-
format!("Timeout while retrieving state root for epoch {}", epoch);
124-
125119
with_timeout(
126-
*MAX_POLL_TIME, /* timeout */
127-
msg, /* error */
120+
*MAX_POLL_TIME,
121+
format!("Timeout while retrieving state root for epoch {}", epoch),
128122
self.with_io(|io| self.handler.state_roots.request_now(io, epoch)),
129123
)
130124
.await
@@ -135,35 +129,20 @@ impl QueryService {
135129
) -> Result<Option<Vec<u8>>, String> {
136130
trace!("retrieve_state_entry epoch = {}, key = {:?}", epoch, key);
137131

138-
// We cannot await in scope that contains call to format!
139-
// This is likely to be fixed in a future compiler version.
140-
// See: https://github.com/rust-lang/rust/issues/64960
141-
let msg = format!(
142-
"Timeout while retrieving state entry for epoch {} with key {:?}",
143-
epoch, key
144-
);
145-
146132
with_timeout(
147-
*MAX_POLL_TIME, /* timeout */
148-
msg, /* error */
149-
self.with_io(|io| {
150-
self.handler.state_entries.request_now(io, epoch, key)
151-
}),
133+
*MAX_POLL_TIME,
134+
format!("Timeout while retrieving state entry for epoch {} with key {:?}", epoch, key),
135+
self.with_io(|io| self.handler.state_entries.request_now(io, epoch, key)),
152136
)
153137
.await
154138
}
155139

156140
async fn retrieve_bloom(&self, epoch: u64) -> Result<(u64, Bloom), String> {
157141
trace!("retrieve_bloom epoch = {}", epoch);
158142

159-
// We cannot await in scope that contains call to format!
160-
// This is likely to be fixed in a future compiler version.
161-
// See: https://github.com/rust-lang/rust/issues/64960
162-
let msg = format!("Timeout while retrieving bloom for epoch {}", epoch);
163-
164143
with_timeout(
165-
*MAX_POLL_TIME, /* timeout */
166-
msg, /* error */
144+
*MAX_POLL_TIME,
145+
format!("Timeout while retrieving bloom for epoch {}", epoch),
167146
self.handler.blooms.request(epoch),
168147
)
169148
.await
@@ -175,15 +154,9 @@ impl QueryService {
175154
) -> Result<(u64, Vec<Vec<Receipt>>), String> {
176155
trace!("retrieve_receipts epoch = {}", epoch);
177156

178-
// We cannot await in scope that contains call to format!
179-
// This is likely to be fixed in a future compiler version.
180-
// See: https://github.com/rust-lang/rust/issues/64960
181-
let msg =
182-
format!("Timeout while retrieving receipts for epoch {}", epoch);
183-
184157
with_timeout(
185-
*MAX_POLL_TIME, /* timeout */
186-
msg, /* error */
158+
*MAX_POLL_TIME,
159+
format!("Timeout while retrieving receipts for epoch {}", epoch),
187160
self.handler.receipts.request(epoch),
188161
)
189162
.await
@@ -196,15 +169,9 @@ impl QueryService {
196169
trace!("retrieve_block_txs log = {:?}", log);
197170
let hash = log.block_hash;
198171

199-
// We cannot await in scope that contains call to format!
200-
// This is likely to be fixed in a future compiler version.
201-
// See: https://github.com/rust-lang/rust/issues/64960
202-
let msg =
203-
format!("Timeout while retrieving block txs for block {}", hash);
204-
205172
with_timeout(
206-
*MAX_POLL_TIME, /* timeout */
207-
msg, /* error */
173+
*MAX_POLL_TIME,
174+
format!("Timeout while retrieving block txs for block {}", hash),
208175
self.handler.block_txs.request(hash),
209176
)
210177
.await
@@ -216,14 +183,9 @@ impl QueryService {
216183
) -> Result<(SignedTransaction, Receipt, TransactionAddress), String> {
217184
trace!("retrieve_tx_info hash = {:?}", hash);
218185

219-
// We cannot await in scope that contains call to format!
220-
// This is likely to be fixed in a future compiler version.
221-
// See: https://github.com/rust-lang/rust/issues/64960
222-
let msg = format!("Timeout while retrieving tx info for tx {}", hash);
223-
224186
with_timeout(
225-
*MAX_POLL_TIME, /* timeout */
226-
msg, /* error */
187+
*MAX_POLL_TIME,
188+
format!("Timeout while retrieving tx info for tx {}", hash),
227189
self.with_io(|io| self.handler.tx_infos.request_now(io, hash)),
228190
)
229191
.await
@@ -374,15 +336,9 @@ impl QueryService {
374336
) -> Result<SignedTransaction, String> {
375337
info!("get_tx hash={:?}", hash);
376338

377-
// We cannot await in scope that contains call to format!
378-
// This is likely to be fixed in a future compiler version.
379-
// See: https://github.com/rust-lang/rust/issues/64960
380-
let msg =
381-
format!("Timeout while retrieving transaction with hash {}", hash);
382-
383339
with_timeout(
384-
*MAX_POLL_TIME, /* timeout */
385-
msg, /* error */
340+
*MAX_POLL_TIME,
341+
format!("Timeout while retrieving transaction with hash {}", hash),
386342
self.with_io(|io| self.handler.txs.request_now(io, hash)),
387343
)
388344
.await

0 commit comments

Comments
 (0)
Please sign in to comment.