Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions crates/core/src/db/datastore/system_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,18 @@ impl From<StRowLevelSecurityRow> for RowLevelSecuritySchema {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ModuleKind(u8);

/// The [`ModuleKind`] of WASM-based modules.
///
/// This is currently the only known kind.
pub const WASM_MODULE: ModuleKind = ModuleKind(0);
impl ModuleKind {
/// The [`ModuleKind`] of WASM-based modules.
pub const WASM: ModuleKind = ModuleKind(0);
}

impl From<crate::messages::control_db::HostType> for ModuleKind {
fn from(host_type: crate::messages::control_db::HostType) -> Self {
match host_type {
crate::messages::control_db::HostType::Wasm => Self::WASM,
}
}
}

impl_serialize!([] ModuleKind, (self, ser) => self.0.serialize(ser));
impl_deserialize!([] ModuleKind, de => u8::deserialize(de).map(Self));
Expand Down Expand Up @@ -852,7 +860,7 @@ impl From<Identity> for IdentityViaU256 {
///
/// * `database_identity` is the [`Identity`] of the database.
/// * `owner_identity` is the [`Identity`] of the owner of the database.
/// * `program_kind` is the [`ModuleKind`] (currently always [`WASM_MODULE`]).
/// * `program_kind` is the [`ModuleKind`] (currently always [`ModuleKind::WASM`]).
/// * `program_hash` is the [`Hash`] of the raw bytes of the (compiled) module.
/// * `program_bytes` are the raw bytes of the (compiled) module.
/// * `module_version` is the version of the module.
Expand Down
11 changes: 3 additions & 8 deletions crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use super::datastore::{
traits::TxData,
};
use super::db_metrics::DB_METRICS;
use crate::db::datastore::system_tables::{StModuleRow, WASM_MODULE};
use crate::db::datastore::system_tables::StModuleRow;
use crate::error::{DBError, DatabaseError, RestoreSnapshotError};
use crate::execution_context::{ReducerContext, Workload, WorkloadType};
use crate::messages::control_db::HostType;
Expand Down Expand Up @@ -427,9 +427,7 @@ impl RelationalDB {
database_identity: self.database_identity.into(),
owner_identity: self.owner_identity.into(),

program_kind: match host_type {
HostType::Wasm => WASM_MODULE,
},
program_kind: host_type.into(),
program_hash: program.hash,
program_bytes: program.bytes,
module_version: ONLY_MODULE_VERSION.into(),
Expand Down Expand Up @@ -473,10 +471,7 @@ impl RelationalDB {
/// - the `__init__` reducer contained in the module has been executed
/// within the transactional context `tx`.
pub fn update_program(&self, tx: &mut MutTx, host_type: HostType, program: Program) -> Result<(), DBError> {
let program_kind = match host_type {
HostType::Wasm => WASM_MODULE,
};
Ok(self.inner.update_program(tx, program_kind, program)?)
Ok(self.inner.update_program(tx, host_type.into(), program)?)
}

fn restore_from_snapshot_or_bootstrap(
Expand Down
Loading