Skip to content

Commit

Permalink
Fix ocex rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Dec 6, 2023
1 parent 82b93af commit 379849e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions pallets/ocex/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ use jsonrpsee::{
use orderbook_primitives::recovery::{DeviationMap, ObCheckpoint, ObRecoveryState};
pub use pallet_ocex_runtime_api::PolkadexOcexRuntimeApi;
use parity_scale_codec::{Codec, Decode};
use parking_lot::RwLock;
use polkadex_primitives::AssetId;
use sc_rpc_api::DenyUnsafe;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_core::offchain::OffchainStorage;
use sp_core::offchain::{storage::OffchainDb, OffchainDbExt, OffchainStorage};
use sp_runtime::traits::Block as BlockT;
use std::sync::Arc;
use sp_core::offchain::OffchainDbExt;
use sp_core::offchain::storage::OffchainDb;

const RUNTIME_ERROR: i32 = 1;
const RETRIES: u8 = 3;
Expand Down Expand Up @@ -194,7 +191,7 @@ where
};

api.register_extension(OffchainDbExt::new(self.offchain_db.clone()));
let mut offchain_storage = offchain::OffchainStorageAdapter::new(self.offchain_db.clone());
let mut offchain_storage = offchain::OffchainStorageAdapter::new(self.offchain_db.clone());
if !offchain_storage.acquire_offchain_lock(RETRIES).await {
return Err(runtime_error_into_rpc_err("Failed to acquire offchain lock"))
}
Expand Down
6 changes: 3 additions & 3 deletions pallets/ocex/rpc/src/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
//! This adapter is used by `function_handler` to access offchain storage.
use parity_scale_codec::Encode;
use sp_core::offchain::{DbExternalities, OffchainStorage, StorageKind};
use sp_core::offchain::storage::OffchainDb;
use sp_core::offchain::{storage::OffchainDb, DbExternalities, OffchainStorage, StorageKind};

pub const WORKER_STATUS: [u8; 28] = *b"offchain-ocex::worker_status";

Expand Down Expand Up @@ -68,6 +67,7 @@ impl<T: OffchainStorage> OffchainStorageAdapter<T> {
impl<T: OffchainStorage> Drop for OffchainStorageAdapter<T> {
fn drop(&mut self) {
let encoded_value = Encode::encode(&false);
self.storage.local_storage_set(StorageKind::PERSISTENT, &WORKER_STATUS, &encoded_value);
self.storage
.local_storage_set(StorageKind::PERSISTENT, &WORKER_STATUS, &encoded_value);
}
}
2 changes: 1 addition & 1 deletion runtimes/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 314,
spec_version: 315,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 3,
Expand Down

0 comments on commit 379849e

Please sign in to comment.