-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(light cull): poll light cull instead of timer #10559
Conversation
rpc/src/v1/helpers/light_fetch.rs
Outdated
pub fn light_cull(&self, txq: Arc<RwLock<TransactionQueue>>) -> impl Future <Item = (), Error = Error> + Send { | ||
let senders = txq.read().queued_senders(); | ||
if senders.is_empty() { | ||
return Either::B(future::err(errors::no_light_transactions())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very unlikely to happen but it could happen if there is a race with calls to eth_getTransactionByHash
i.e, a cull
finished just between the transaction_by_hash and light_cull.
Then don't do a needless network request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should leave this is a comment within the code, just in case
if in_txqueue { | ||
// Note, this will block (relies on HTTP timeout) to make sure `cull` will finish to avoid having to call | ||
// `eth_getTransactionByHash` more than once to ensure the `txqueue` is up to `date` when it is called | ||
if let Err(e) = self.fetcher().light_cull(self.transaction_queue.clone()).wait() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the most controversial thing about this PR.
The light_cull
could be spawned in an executor but then we would most likely not get result in this call (accessing an atomic variable is much faster than a network request) and we would have to call this at least one more time to get the result!
d338c0a
to
23d41cb
Compare
* master: fix(light cull): poll light cull instead of timer (#10559) Update Issue Template to direct security issue to email (#10562) RPC: Implements eth_subscribe("syncing") (#10311) Explicitly enable or disable Stratum in config file (Issue 9785) (#10521) version: bump master to 2.6 (#10560) tx-pool: check transaction readiness before replacing (#10526) fix(light account response): update `tx_queue` (#10545) Update light client harcoded headers (#10547) fix(light eth_gasPrice): ask network if not in cache (#10535) Implement caching for service transactions checker (#10088) build android with cache, win fixes (#10546) clique: make state backfill time measurement more accurate (#10551) updated lru-cache to 0.1.2 (#10542)
* fix(light cull): poll light cull instead of timer * fix(grumbles): remove error + updated docs * fix(on-demand request): `expect()` reason * docs(remove misleading info)
* Reject crazy timestamps instead of truncating. * fix(light cull): poll light cull instead of timer (#10559) * fix(light cull): poll light cull instead of timer * fix(grumbles): remove error + updated docs * fix(on-demand request): `expect()` reason * docs(remove misleading info)
* Reject crazy timestamps instead of truncating. * fix(light cull): poll light cull instead of timer (openethereum#10559) * fix(light cull): poll light cull instead of timer * fix(grumbles): remove error + updated docs * fix(on-demand request): `expect()` reason * docs(remove misleading info) running code return data is working
cull polling
on every call oneth_getTransactiobByHash
requestcull service
which used a hardcoded timer every 10th minute