extra logs
This commit is contained in:
committed by
Mark Sinclair
parent
34436c48b2
commit
f1b4ebdbae
@@ -117,6 +117,8 @@ impl BlockProcessor {
|
||||
let last_pruned = storage.get_pruned_height().await?;
|
||||
let last_pruned_height = last_pruned.try_into().unwrap_or_default();
|
||||
|
||||
debug!(last_processed_height = %last_processed_height, pruned_height = %last_pruned_height, "setting up block processor...");
|
||||
|
||||
Ok(BlockProcessor {
|
||||
config,
|
||||
cancel,
|
||||
@@ -399,12 +401,15 @@ impl BlockProcessor {
|
||||
// but we need it to help the compiler figure out the future is `Send`
|
||||
async fn startup_resync(&mut self) -> Result<(), ScraperError> {
|
||||
assert!(self.pending_sync.is_empty());
|
||||
info!("attempting to run startup resync...");
|
||||
|
||||
self.maybe_prune_storage().await?;
|
||||
|
||||
let latest_block = self.rpc_client.current_block_height().await? as u32;
|
||||
info!("obtained latest block height: {latest_block}");
|
||||
|
||||
if latest_block > self.last_processed_height && self.last_processed_height != 0 {
|
||||
info!("we have already processed some blocks in the past - attempting to resume...");
|
||||
// in case we were offline for a while,
|
||||
// make sure we don't request blocks we'd have to prune anyway
|
||||
let keep_recent = self.config.pruning_options.strategy_keep_recent();
|
||||
@@ -419,7 +424,9 @@ impl BlockProcessor {
|
||||
|
||||
// this is the first time starting up
|
||||
if self.last_processed_height == 0 {
|
||||
info!("this is the first time starting up");
|
||||
let Some(starting_height) = self.config.explicit_starting_block_height else {
|
||||
info!("no starting block height set - will use the default behaviour");
|
||||
// nothing to do
|
||||
return Ok(());
|
||||
};
|
||||
@@ -456,7 +463,7 @@ impl BlockProcessor {
|
||||
}
|
||||
|
||||
pub(crate) async fn run(&mut self) {
|
||||
info!("starting processing loop");
|
||||
info!("starting block processor processing loop");
|
||||
|
||||
// sure, we could be more efficient and reset it on every processed block,
|
||||
// but the overhead is so minimal that it doesn't matter
|
||||
|
||||
@@ -139,7 +139,7 @@ pub struct NyxdScraper {
|
||||
task_tracker: TaskTracker,
|
||||
cancel_token: CancellationToken,
|
||||
startup_sync: Arc<Notify>,
|
||||
pub storage: ScraperStorage,
|
||||
storage: ScraperStorage,
|
||||
rpc_client: RpcClient,
|
||||
}
|
||||
|
||||
@@ -163,6 +163,10 @@ impl NyxdScraper {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn storage(&self) -> ScraperStorage {
|
||||
self.storage.clone()
|
||||
}
|
||||
|
||||
fn start_tasks(
|
||||
&self,
|
||||
mut block_requester: BlockRequester,
|
||||
|
||||
@@ -55,6 +55,12 @@ pub(crate) fn log_db_operation_time(op_name: &str, start_time: Instant) {
|
||||
impl ScraperStorage {
|
||||
#[instrument]
|
||||
pub async fn init<P: AsRef<Path> + Debug>(database_path: P) -> Result<Self, ScraperError> {
|
||||
let database_path = database_path.as_ref();
|
||||
debug!(
|
||||
"initialising scraper database path to '{}'",
|
||||
database_path.display()
|
||||
);
|
||||
|
||||
let opts = sqlx::sqlite::SqliteConnectOptions::new()
|
||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||
.synchronous(SqliteSynchronous::Normal)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use crate::env::vars::{NYXD_SCRAPER_START_HEIGHT, NYXD_SCRAPER_USE_BEST_EFFORT_START_HEIGHT};
|
||||
use nyxd_scraper::{storage::ScraperStorage, NyxdScraper, PruningOptions};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn run_chain_scraper(
|
||||
config: &crate::config::Config,
|
||||
) -> anyhow::Result<ScraperStorage> {
|
||||
) -> anyhow::Result<NyxdScraper> {
|
||||
let websocket_url = std::env::var("NYXD_WS").expect("NYXD_WS not defined");
|
||||
|
||||
let rpc_url = std::env::var("NYXD").expect("NYXD not defined");
|
||||
@@ -38,5 +39,8 @@ pub(crate) async fn run_chain_scraper(
|
||||
|
||||
let instance = scraper.build_and_start().await?;
|
||||
|
||||
Ok(instance.storage)
|
||||
info!("🚧 blocking until the chain has caught up...");
|
||||
instance.wait_for_startup_sync().await;
|
||||
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ pub(crate) async fn execute(args: Args, http_port: u16) -> Result<(), NyxChainWa
|
||||
// Spawn the payment listener task
|
||||
let payment_listener_handle = tokio::spawn({
|
||||
let obs_pool = watcher_pool.clone();
|
||||
let chain_storage = run_chain_scraper(&config).await?;
|
||||
let chain_scraper = run_chain_scraper(&config).await?;
|
||||
let chain_storage = chain_scraper.storage();
|
||||
let payment_watcher_config = config.payment_watcher_config.unwrap_or_default();
|
||||
|
||||
async move {
|
||||
|
||||
Reference in New Issue
Block a user