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
8 changes: 1 addition & 7 deletions crates/core/src/host/module_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,7 @@ impl ModuleHost {
self.inner.get_instance(self.info.database_identity).await?
};

let result = tokio::task::spawn_blocking(move || f(&mut *inst))
.await
.unwrap_or_else(|e| {
log::warn!("reducer `{reducer}` panicked");
(self.on_panic)();
std::panic::resume_unwind(e.into_panic())
});
let result = f(&mut *inst);
Ok(result)
}

Expand Down
62 changes: 0 additions & 62 deletions crates/standalone/src/energy_monitor.rs

This file was deleted.

23 changes: 6 additions & 17 deletions crates/standalone/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
mod control_db;
mod energy_monitor;
pub mod subcommands;
pub mod util;
pub mod version;

use crate::control_db::ControlDb;
use crate::subcommands::start;
use anyhow::{ensure, Context};
use anyhow::{ensure, Context, Ok};
use async_trait::async_trait;
use clap::{ArgMatches, Command};
use energy_monitor::StandaloneEnergyMonitor;
use spacetimedb::client::ClientActorIndex;
use spacetimedb::config::{CertificateAuthority, MetadataFile};
use spacetimedb::db::db_metrics::data_size::DATA_SIZE_METRICS;
use spacetimedb::db::relational_db;
use spacetimedb::db::{db_metrics::DB_METRICS, Config};
use spacetimedb::energy::{EnergyBalance, EnergyQuanta};
use spacetimedb::energy::{EnergyBalance, EnergyQuanta, NullEnergyMonitor};
use spacetimedb::host::{
DiskStorage, DurabilityProvider, ExternalDurability, HostController, StartSnapshotWatcher, UpdateDatabaseResult,
};
Expand Down Expand Up @@ -56,7 +54,7 @@ impl StandaloneEnv {
meta.write(&meta_path).context("failed writing metadata.toml")?;

let control_db = ControlDb::new(&data_dir.control_db()).context("failed to initialize control db")?;
let energy_monitor = Arc::new(StandaloneEnergyMonitor::new(control_db.clone()));
let energy_monitor = Arc::new(NullEnergyMonitor);
let program_store = Arc::new(DiskStorage::new(data_dir.program_bytes().0).await?);

let durability_provider = Arc::new(StandaloneDurabilityProvider {
Expand Down Expand Up @@ -347,8 +345,9 @@ impl spacetimedb_client_api::ControlStateWriteAccess for StandaloneEnv {
self.control_db.set_energy_balance(*identity, balance)?;
Ok(())
}
async fn withdraw_energy(&self, identity: &Identity, amount: EnergyQuanta) -> anyhow::Result<()> {
withdraw_energy(&self.control_db, identity, amount)
async fn withdraw_energy(&self, _identity: &Identity, _amount: EnergyQuanta) -> anyhow::Result<()> {
// The energy balance code is obsolete.
Ok(())
}

async fn register_tld(&self, identity: &Identity, tld: Tld) -> anyhow::Result<RegisterTldResult> {
Expand Down Expand Up @@ -439,16 +438,6 @@ impl StandaloneEnv {
}
}

fn withdraw_energy(control_db: &ControlDb, identity: &Identity, amount: EnergyQuanta) -> anyhow::Result<()> {
let energy_balance = control_db.get_energy_balance(identity)?;
let energy_balance = energy_balance.unwrap_or(EnergyBalance::ZERO);
log::trace!("Withdrawing {} from {}", amount, identity);
log::trace!("Old balance: {}", energy_balance);
let new_balance = energy_balance.saturating_sub_energy(amount);
control_db.set_energy_balance(*identity, new_balance)?;
Ok(())
}

pub async fn exec_subcommand(cmd: &str, args: &ArgMatches) -> Result<(), anyhow::Error> {
match cmd {
"start" => start::exec(args).await,
Expand Down
Loading