mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 09:41:07 +00:00
deps: replace lru with schnellru (#1217)
* deps: replace lru with schnellru * bring the peace to the galaxy
This commit is contained in:
@@ -34,7 +34,7 @@ async-trait = "0.1.73"
|
||||
url = "2.4.0"
|
||||
serde_json = "1.0.105"
|
||||
serde = "1.0.183"
|
||||
lru = "0.11.0"
|
||||
schnellru = "0.2.1"
|
||||
smoldot = { version = "0.11.0", default_features = false, features = ["std"]}
|
||||
smoldot-light = { version = "0.9.0", default_features = false, features = ["std"] }
|
||||
either = "1.8.1"
|
||||
|
||||
@@ -31,10 +31,10 @@ use jsonrpsee::{
|
||||
},
|
||||
ws_client::WsClientBuilder,
|
||||
};
|
||||
use lru::LruCache;
|
||||
use sc_rpc_api::chain::ChainApiClient;
|
||||
use schnellru::{ByLength, LruMap};
|
||||
use sp_runtime::generic::SignedBlock;
|
||||
use std::{num::NonZeroUsize, sync::Arc};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::mpsc::{
|
||||
channel as tokio_channel, Receiver as TokioReceiver, Sender as TokioSender,
|
||||
};
|
||||
@@ -307,8 +307,7 @@ impl ReconnectingWebsocketWorker {
|
||||
return
|
||||
};
|
||||
|
||||
let mut imported_blocks_cache =
|
||||
LruCache::new(NonZeroUsize::new(40).expect("40 is nonzero; qed."));
|
||||
let mut imported_blocks_cache = LruMap::new(ByLength::new(40));
|
||||
let mut should_reconnect = ConnectionStatus::Connected;
|
||||
let mut last_seen_finalized_num: RelayNumber = 0;
|
||||
loop {
|
||||
@@ -365,7 +364,7 @@ impl ReconnectingWebsocketWorker {
|
||||
match import_event {
|
||||
Some(Ok(header)) => {
|
||||
let hash = header.hash();
|
||||
if imported_blocks_cache.contains(&hash) {
|
||||
if imported_blocks_cache.peek(&hash).is_some() {
|
||||
tracing::debug!(
|
||||
target: LOG_TARGET,
|
||||
number = header.number,
|
||||
@@ -374,7 +373,7 @@ impl ReconnectingWebsocketWorker {
|
||||
);
|
||||
continue;
|
||||
}
|
||||
imported_blocks_cache.put(hash, ());
|
||||
imported_blocks_cache.insert(hash, ());
|
||||
distribute_header(header, &mut self.imported_header_listeners);
|
||||
},
|
||||
None => {
|
||||
|
||||
Reference in New Issue
Block a user