using sqlite instance for rewarder and chain watcher
This commit is contained in:
@@ -15,3 +15,4 @@ pub use block_processor::pruning::{PruningOptions, PruningStrategy};
|
||||
pub use block_processor::types::ParsedTransactionResponse;
|
||||
pub use modules::{BlockModule, MsgModule, TxModule};
|
||||
pub use scraper::{Config, NyxdScraper, StartingBlockOpts};
|
||||
pub use storage::{NyxdScraperStorage, NyxdScraperTransaction};
|
||||
|
||||
@@ -174,6 +174,10 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
pub fn storage(&self) -> &S {
|
||||
&self.storage
|
||||
}
|
||||
|
||||
fn start_tasks(
|
||||
&self,
|
||||
mut block_requester: BlockRequester,
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::storage::block_storage::SqliteScraperStorage;
|
||||
use nyxd_scraper_shared::NyxdScraper;
|
||||
|
||||
pub use nyxd_scraper_shared::constants;
|
||||
pub use nyxd_scraper_shared::error::ScraperError;
|
||||
pub use nyxd_scraper_shared::{
|
||||
BlockModule, MsgModule, NyxdScraperTransaction, ParsedTransactionResponse, PruningOptions,
|
||||
PruningStrategy, StartingBlockOpts, TxModule,
|
||||
};
|
||||
pub use storage::models;
|
||||
|
||||
pub mod error;
|
||||
pub mod storage;
|
||||
|
||||
pub use storage::models;
|
||||
pub type SqliteNyxdScraper = NyxdScraper<SqliteScraperStorage>;
|
||||
|
||||
// TODO: for now just use exactly the same config
|
||||
pub use nyxd_scraper_shared::Config;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::cli::{try_load_current_config, ConfigOverridableArgs};
|
||||
use crate::error::NymRewarderError;
|
||||
use nyxd_scraper_sqlite::NyxdScraper;
|
||||
use nyxd_scraper_sqlite::SqliteNyxdScraper;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, clap::Args)]
|
||||
@@ -24,7 +24,7 @@ pub(crate) async fn execute(args: Args) -> Result<(), NymRewarderError> {
|
||||
let config =
|
||||
try_load_current_config(&args.custom_config_path)?.with_override(args.config_override);
|
||||
|
||||
NyxdScraper::new(config.scraper_config())
|
||||
SqliteNyxdScraper::new(config.scraper_config())
|
||||
.await?
|
||||
.unsafe_process_single_block(args.height)
|
||||
.await?;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::cli::{try_load_current_config, ConfigOverridableArgs};
|
||||
use crate::error::NymRewarderError;
|
||||
use nyxd_scraper_sqlite::NyxdScraper;
|
||||
use nyxd_scraper_sqlite::SqliteNyxdScraper;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, clap::Args)]
|
||||
@@ -37,7 +37,7 @@ pub(crate) async fn execute(args: Args) -> Result<(), NymRewarderError> {
|
||||
let config =
|
||||
try_load_current_config(&args.custom_config_path)?.with_override(args.config_override);
|
||||
|
||||
NyxdScraper::new(config.scraper_config())
|
||||
SqliteNyxdScraper::new(config.scraper_config())
|
||||
.await?
|
||||
.unsafe_process_block_range(args.start_height, args.stop_height)
|
||||
.await?;
|
||||
|
||||
@@ -9,6 +9,7 @@ use nym_validator_client::nym_api::error::NymAPIError;
|
||||
use nym_validator_client::nyxd::error::NyxdError;
|
||||
use nym_validator_client::nyxd::tx::ErrorReport;
|
||||
use nym_validator_client::nyxd::{AccountId, Coin};
|
||||
use nyxd_scraper_sqlite::error::SqliteScraperError;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
use thiserror::Error;
|
||||
@@ -78,7 +79,13 @@ pub enum NymRewarderError {
|
||||
#[error("chain scraping failure: {source}")]
|
||||
ScraperFailure {
|
||||
#[from]
|
||||
source: nyxd_scraper_sqlite::error::ScraperError,
|
||||
source: nyxd_scraper_sqlite::ScraperError,
|
||||
},
|
||||
|
||||
#[error("chain scraper storage failure: {source}")]
|
||||
ScraperStorageFailure {
|
||||
#[from]
|
||||
source: SqliteScraperError,
|
||||
},
|
||||
|
||||
// this should never happen but unwrapping everywhere was more cumbersome than just propagating the error
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::rewarder::epoch::Epoch;
|
||||
use crate::rewarder::nyxd_client::NyxdClient;
|
||||
use nym_validator_client::nyxd::module_traits::staking;
|
||||
use nym_validator_client::nyxd::{AccountId, PageRequest};
|
||||
use nyxd_scraper_sqlite::NyxdScraper;
|
||||
use nyxd_scraper_sqlite::SqliteNyxdScraper;
|
||||
use std::cmp::min;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Range;
|
||||
@@ -17,7 +17,7 @@ pub(crate) mod types;
|
||||
|
||||
pub struct EpochSigning {
|
||||
pub(crate) nyxd_client: NyxdClient,
|
||||
pub(crate) nyxd_scraper: NyxdScraper,
|
||||
pub(crate) nyxd_scraper: SqliteNyxdScraper,
|
||||
pub(crate) whitelist: Vec<AccountId>,
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use nym_crypto::asymmetric::ed25519;
|
||||
use nym_ecash_time::{ecash_today, ecash_today_date, EcashTime};
|
||||
use nym_task::TaskManager;
|
||||
use nym_validator_client::nyxd::{AccountId, Coin, Hash};
|
||||
use nyxd_scraper_sqlite::NyxdScraper;
|
||||
use nyxd_scraper_sqlite::SqliteNyxdScraper;
|
||||
use std::sync::Arc;
|
||||
use time::Date;
|
||||
use tokio::pin;
|
||||
@@ -188,7 +188,7 @@ impl Rewarder {
|
||||
info!("the block signing rewarding is running in monitor only mode");
|
||||
}
|
||||
|
||||
let nyxd_scraper = NyxdScraper::new(config.scraper_config()).await?;
|
||||
let nyxd_scraper = SqliteNyxdScraper::new(config.scraper_config()).await?;
|
||||
|
||||
Some(EpochSigning {
|
||||
nyxd_scraper,
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::http::state::BankScraperModuleState;
|
||||
use async_trait::async_trait;
|
||||
use nym_validator_client::nyxd::{Any, Coin, CosmosCoin, Hash, Msg, MsgSend, Name};
|
||||
use nyxd_scraper_sqlite::{
|
||||
error::ScraperError, storage::StorageTransaction, MsgModule, NyxdScraper,
|
||||
ParsedTransactionResponse, PruningOptions,
|
||||
MsgModule, NyxdScraperTransaction, ParsedTransactionResponse, PruningOptions, ScraperError,
|
||||
SqliteNyxdScraper,
|
||||
};
|
||||
use sqlx::SqlitePool;
|
||||
use std::fs;
|
||||
@@ -18,7 +18,7 @@ pub(crate) async fn run_chain_scraper(
|
||||
config: &crate::config::Config,
|
||||
db_pool: SqlitePool,
|
||||
shared_state: BankScraperModuleState,
|
||||
) -> anyhow::Result<NyxdScraper> {
|
||||
) -> anyhow::Result<SqliteNyxdScraper> {
|
||||
let websocket_url = std::env::var("NYXD_WS").expect("NYXD_WS not defined");
|
||||
|
||||
let rpc_url = std::env::var("NYXD").expect("NYXD not defined");
|
||||
@@ -50,7 +50,7 @@ pub(crate) async fn run_chain_scraper(
|
||||
fs::remove_file(config.chain_scraper_database_path())?;
|
||||
}
|
||||
|
||||
let scraper = NyxdScraper::builder(nyxd_scraper_sqlite::Config {
|
||||
let scraper = SqliteNyxdScraper::builder(nyxd_scraper_sqlite::Config {
|
||||
websocket_url,
|
||||
rpc_url,
|
||||
database_path: config.chain_scraper_database_path().into(),
|
||||
@@ -157,7 +157,7 @@ impl MsgModule for BankScraperModule {
|
||||
index: usize,
|
||||
msg: &Any,
|
||||
tx: &ParsedTransactionResponse,
|
||||
_storage_tx: &mut StorageTransaction,
|
||||
_storage_tx: &mut dyn NyxdScraperTransaction,
|
||||
) -> Result<(), ScraperError> {
|
||||
let memo = tx.tx.body.memo.clone();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user