Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
NYBACHOK committed Nov 8, 2024
1 parent 8013546 commit 34da41a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gears/src/baseapp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ impl<DB: Database, PSK: ParamsSubspaceKey, H: ABCIHandler, AI: ApplicationInfo>

fn run_query(&self, request: &RequestQuery) -> Result<Bytes, QueryError> {
//TODO: request height u32
let version: NonZero<u32> = NonZero::new(
let version = NonZero::new(
request
.height
.try_into()
.map_err(|_| QueryError::InvalidHeight)?,
)
.ok_or(QueryError::InvalidHeight)?;
);

let store = self.multi_store.read().expect(POISONED_LOCK);
let ctx = QueryContext::new(QueryMultiStore::new(&*store, Some(version))?, version.get())?;
let ctx = QueryContext::new(
QueryMultiStore::new(&*store, version)?,
version.map(|this| this.get()).unwrap_or_default(),
)?;

self.abci_handler
.query(&ctx, request.clone())
Expand Down
2 changes: 2 additions & 0 deletions gears/src/baseapp/mode/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use crate::{
},
};

/// Specific to `check_tx` ABCI method.
///
/// Mode to validate a transaction before letting
/// them into local mempool. This mode doesn't execute a
/// transaction only runs ante checks on them.
Expand Down
2 changes: 2 additions & 0 deletions gears/src/baseapp/mode/deliver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use crate::{
types::tx::raw::TxWithRaw,
};

/// Specific to `deliver_tx` ABCI method.
///
/// Mode to execute transactions. This mode still run
/// ante checks, but you may skip execution by checking
/// `bool` flag in ante method. Futhermore this module
Expand Down
8 changes: 8 additions & 0 deletions gears/src/baseapp/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use crate::{

use super::mode::{check::CheckTxMode, deliver::DeliverTxMode};

/// Structure to hide state logic from application
/// and sync state between different modes during blocks
#[derive(Debug)]
pub struct ApplicationState<DB, AH: ABCIHandler> {
pub(super) check_mode: CheckTxMode<DB, AH>,
Expand All @@ -26,6 +28,8 @@ impl<DB: Database, AH: ABCIHandler> ApplicationState<DB, AH> {
}
}

/// Update gas meter for block metering. This method should be called in each `begin_block`
/// to update meter according to [crate::baseapp::params::BlockParams]
pub fn replace_meter(&mut self, max_gas: Gas) {
match max_gas {
Gas::Infinite => {
Expand Down Expand Up @@ -64,6 +68,10 @@ impl<DB: Database, AH: ABCIHandler> ApplicationState<DB, AH> {
}
}

/// Commit changes from state store to application and persist changes to disk.
/// Returns application state hash.
///
/// **Note**: changes from `check_tx` state is discarded and instead `deliver_tx` state used.
pub fn commit(&mut self, multi_store: &mut ApplicationMultiBank<DB, AH::StoreKey>) -> [u8; 32] {
self.check_mode.multi_store.tx_cache_clear();
self.check_mode.multi_store.block_cache_clear();
Expand Down

0 comments on commit 34da41a

Please sign in to comment.