feat(storage): log tx opening location (#5973)

This commit is contained in:
Alexey Shekhirin
2024-01-08 19:01:17 +00:00
committed by GitHub
parent bb7dcfaf12
commit 189cf490eb
4 changed files with 28 additions and 5 deletions

View File

@ -101,6 +101,7 @@ impl<DB: Database> ProviderFactory<DB> {
/// Returns a provider with a created `DbTx` inside, which allows fetching data from the
/// database using different types of providers. Example: [`HeaderProvider`]
/// [`BlockHashReader`]. This may fail if the inner read database transaction fails to open.
#[track_caller]
pub fn provider(&self) -> ProviderResult<DatabaseProviderRO<DB>> {
let mut provider = DatabaseProvider::new(self.db.tx()?, self.chain_spec.clone());
@ -115,6 +116,7 @@ impl<DB: Database> ProviderFactory<DB> {
/// data from the database using different types of providers. Example: [`HeaderProvider`]
/// [`BlockHashReader`]. This may fail if the inner read/write database transaction fails to
/// open.
#[track_caller]
pub fn provider_rw(&self) -> ProviderResult<DatabaseProviderRW<DB>> {
let mut provider = DatabaseProvider::new_rw(self.db.tx_mut()?, self.chain_spec.clone());
@ -126,6 +128,7 @@ impl<DB: Database> ProviderFactory<DB> {
}
/// Storage provider for latest block
#[track_caller]
pub fn latest(&self) -> ProviderResult<StateProviderBox> {
trace!(target: "providers::db", "Returning latest state provider");
Ok(Box::new(LatestStateProvider::new(self.db.tx()?)))