Skip to content

Commit

Permalink
Fix build error; fix unused code warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Nov 9, 2024
1 parent 8e168a7 commit 60705fd
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bin/metric_exporter/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Metrics {
}

pub fn inc_bytes(&self, bytes: u64) {
self.bytes.inc_by(bytes as i64)
self.bytes.inc_by(bytes)
}

pub fn gather(&self) -> String {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::path::PathBuf;

use ::serde::Deserialize;
use pallas::crypto::key::ed25519::SecretKey;

pub mod model;
pub mod providers;
Expand Down
7 changes: 0 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
use std::path::PathBuf;

use anyhow::{Context, Result};
use hydra_control_plane::NodeConfig;
use model::cluster::ClusterState;
use rocket::{http::Method, routes};
use rocket_cors::{AllowedOrigins, CorsOptions};
use routes::{add_player::add_player, head::head, heads::heads, new_game::new_game};
use serde::Deserialize;
use tokio::{
spawn,
sync::mpsc::{self, UnboundedReceiver, UnboundedSender},
};
use tracing::{info, warn};

mod model;
mod providers;
Expand Down
3 changes: 2 additions & 1 deletion src/model/cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn define_namespace() -> String {
std::env::var("KUBERNETES_NAMESPACE").unwrap_or_else(|_| DEFAULT_NAMESPACE.to_string())
}

#[allow(dead_code)]
#[derive(Clone)]
pub struct ClusterState {
store: kube::runtime::reflector::Store<HydraDoomNode>,
Expand Down Expand Up @@ -52,7 +53,7 @@ impl ClusterState {
);

let watcher_handle = tokio::spawn(async move {
let infinite_watch = rf.applied_objects().for_each(|o| ready(()));
let infinite_watch = rf.applied_objects().for_each(|_| ready(()));
infinite_watch.await;
});

Expand Down
4 changes: 3 additions & 1 deletion src/model/cluster/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use pallas::{
use reqwest::Url;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use tracing::{debug, info};
use tracing::debug;

use crate::model::{
hydra::{hydra_socket, messages::new_tx::NewTx},
Expand Down Expand Up @@ -41,6 +41,7 @@ pub struct ConnectionInfo {
#[derive(Serialize)]
pub struct NodeSummary(pub NodeClient);

#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct StateUpdate {
pub player: String,
Expand Down Expand Up @@ -190,6 +191,7 @@ impl ConnectionInfo {
format!("{}://{}:{}", schema, self.host, self.port)
}

#[allow(dead_code)]
pub fn to_authority(&self) -> String {
format!("{}:{}", self.host, self.port)
}
Expand Down
1 change: 1 addition & 0 deletions src/model/hydra/contract/hydra_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use pallas::ledger::{addresses::Address, primitives::PlutusScript, traverse::Com

// Named after the scripts here: https://github.com/cardano-scaling/hydra/tree/master/hydra-plutus/scripts
// For more info on what each script does, read the protocol spec: https://hydra.family/head-protocol/assets/files/hydra-spec-74c85a9e8c75aeca7735137947b39453.pdf
#[allow(dead_code)]
pub enum HydraValidator {
MHead,
VCommit,
Expand Down
1 change: 1 addition & 0 deletions src/model/hydra/hydra_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum HydraMessage {
Ping(Vec<u8>),
}

#[allow(dead_code)]
#[derive(Debug)]
pub enum HydraData {
Received {
Expand Down
2 changes: 2 additions & 0 deletions src/model/hydra/hydra_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct HydraSender {
sender: HydraSink,
}

#[allow(dead_code)]
impl HydraSocket {
pub fn new(url: &str, identifier: &str, writer: &UnboundedSender<HydraData>) -> Self {
HydraSocket {
Expand Down Expand Up @@ -145,6 +146,7 @@ impl HydraSocket {
}
}

#[allow(dead_code)]
impl HydraSender {
pub async fn send(&mut self, message: HydraData) -> Result<()> {
match message {
Expand Down
1 change: 1 addition & 0 deletions src/model/hydra/messages/command_failed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Context;
use serde_json::Value;

#[allow(dead_code)]
#[derive(Debug)]
pub struct CommandFailed {
client_input: Value,
Expand Down
1 change: 1 addition & 0 deletions src/model/hydra/messages/init.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(dead_code)]
pub fn get_message() -> String {
"{\"tag\":\"Init\"}".to_string()
}
3 changes: 3 additions & 0 deletions src/model/hydra/tx/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use super::{
script_registry::ScriptRegistry,
};

#[allow(dead_code)]
pub struct CommitTx {
pub network_id: u8,
pub script_registry: ScriptRegistry,
Expand All @@ -27,6 +28,7 @@ pub struct CommitTx {
pub commit_inputs: Vec<(InputWrapper, OutputWrapper)>,
}

#[allow(dead_code)]
impl CommitTx {
pub fn build_tx(&self) -> Result<BuiltTransaction> {
let commit_output = build_base_commit_output(
Expand Down Expand Up @@ -145,6 +147,7 @@ impl CommitTx {
}
}

#[allow(dead_code)]
fn build_base_commit_output(outputs: Vec<Output>, network_id: u8) -> Result<Output> {
// let address = Address::from_bytes(
// hex::decode("702043A9F1A685BCF491413A5F139EE42E335157C8C6BC8D9E4018669D")
Expand Down
2 changes: 2 additions & 0 deletions src/model/hydra/tx/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ use crate::model::hydra::{

use super::{cost_models::COST_MODEL_PLUTUS_V2, input::InputWrapper, void_redeemer};

#[allow(dead_code)]
pub struct InitTx {
pub network_id: u8,
pub seed_input: InputWrapper,
pub participants: Vec<Vec<u8>>,
pub parameters: HeadParameters,
}

#[allow(dead_code)]
impl InitTx {
pub fn get_head_id(&self) -> Result<Vec<u8>> {
Ok(self.get_minting_validator()?.1.to_vec())
Expand Down
2 changes: 2 additions & 0 deletions src/model/hydra/tx/script_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ use pallas::{crypto::hash::Hash, txbuilder::Input};

use super::input::InputWrapper;

#[allow(dead_code)]
#[derive(Clone)]
pub struct ScriptRegistry {
pub initial_reference: InputWrapper,
pub commit_reference: InputWrapper,
pub head_reference: InputWrapper,
}

#[allow(dead_code)]
pub enum NetworkScriptRegistry {
Mainnet,
Preview,
Expand Down
3 changes: 1 addition & 2 deletions src/model/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use pallas::{
},
txbuilder::{BuildConway, BuiltTransaction, ExUnits, Output, ScriptKind, StagingTransaction},
};
use tracing::info;

use crate::model::{
game::contract::redeemer::{Redeemer, SpendAction},
Expand All @@ -18,7 +17,7 @@ use crate::model::{

use super::{
game::contract::{game_state::GameState, validator::Validator},
hydra::{tx::cost_models::COST_MODEL_PLUTUS_V2, utxo::UTxO},
hydra::utxo::UTxO,
};

#[derive(Clone, Debug)]
Expand Down
2 changes: 2 additions & 0 deletions src/providers/blockfrost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ use pallas::{
txbuilder::{BuiltTransaction, Output},
};

#[allow(dead_code)]
pub struct Blockfrost {
api: BlockfrostAPI,
}

#[allow(dead_code)]
impl Blockfrost {
pub fn new(project_id: &str) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/new_game.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ::anyhow::{anyhow, Context};
use pallas::ledger::addresses::Address;
use rocket::{get, serde::json::Json, State};
use rocket_errors::anyhow::{self, AnyhowError, Result};
use rocket_errors::anyhow::Result;
use serde::Serialize;
use tracing::info;

Expand Down

0 comments on commit 60705fd

Please sign in to comment.