Compare commits

..

1 Commits

Author SHA1 Message Date
Peter Zhang
adcc1a7f0d add log 2024-09-02 00:16:36 +08:00
2 changed files with 7 additions and 14 deletions

View File

@ -1,6 +1,6 @@
use ethers::prelude::{Filter, JsonRpcClient, Log, Middleware, Provider, ProviderError, U64};
use futures_core::stream::Stream;
use jsonrpsee::tracing::{debug, error, trace};
use jsonrpsee::tracing::trace;
use std::future::Future;
use std::time::Duration;
use std::{
@ -152,7 +152,6 @@ where
}
}
LogQueryState::LoadLogs((from_block, fut)) => {
debug!("LoadLogs: loading logs from block={:?}", from_block);
match futures_util::ready!(fut.as_mut().poll(ctx)) {
Ok(logs) => {
self.current_logs = VecDeque::from(logs);
@ -164,10 +163,6 @@ where
if err.to_string().contains(msg) {
self.from_block = *from_block;
self.page_size /= 2;
error!(
"log_query: page size to large at {} reducing page size to {}",
self.from_block.unwrap(), self.page_size
);
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
}
}

View File

@ -5,7 +5,7 @@ use anyhow::{anyhow, bail, Result};
use ethereum_types::H256;
use ethers::{prelude::Middleware, types::BlockNumber};
use futures::FutureExt;
use jsonrpsee::tracing::{debug, error, warn};
use jsonrpsee::tracing::{debug, error, trace, warn};
use shared_types::{ChunkArray, Transaction};
use std::collections::BTreeMap;
use std::fmt::Debug;
@ -56,7 +56,7 @@ impl LogSyncManager {
store: Arc<dyn Store>,
) -> Result<(broadcast::Sender<LogSyncEvent>, oneshot::Receiver<()>)> {
let next_tx_seq = store.next_tx_seq();
debug!("LogSyncManager spawn next_tx_seq: {}", next_tx_seq);
let executor_clone = executor.clone();
let mut shutdown_sender = executor.shutdown_sender();
@ -251,8 +251,8 @@ impl LogSyncManager {
}
std::cmp::Ordering::Greater => {
error!(
"Unexpected transaction tx={:?}",
tx,
"Unexpected transaction seq: next={} get={}, hash={}",
self.next_tx_seq, tx.seq, tx.data_merkle_root.to_string()
);
false
}
@ -298,7 +298,7 @@ impl LogSyncManager {
async fn handle_data(&mut self, mut rx: UnboundedReceiver<LogFetchProgress>) -> Result<()> {
while let Some(data) = rx.recv().await {
debug!("handle_data: data={:?}", data);
trace!("handle_data: data={:?}", data);
match data {
LogFetchProgress::SyncedBlock((
block_number,
@ -387,7 +387,7 @@ impl LogSyncManager {
}
}
self.data_cache.garbage_collect(self.next_tx_seq);
self.next_tx_seq = self.store.next_tx_seq();
self.next_tx_seq += 1;
true
}
}
@ -427,7 +427,6 @@ impl LogSyncManager {
&executor_clone,
Duration::from_millis(self.config.recover_query_delay),
);
self.next_tx_seq = self.store.next_tx_seq();
self.handle_data(recover_rx).await?;
}
@ -438,7 +437,6 @@ impl LogSyncManager {
self.config.default_finalized_block_count,
self.config.remove_finalized_block_interval_minutes,
);
Ok(())
}
}