Skip to content

Commit

Permalink
refactor: renamed UpgradeIntentMessage message type
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Aug 15, 2023
1 parent 3c01b0a commit c682968
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
19 changes: 5 additions & 14 deletions src/message_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,22 @@ pub struct SimpleMessage {

#[derive(Eip712, EthAbiType, Clone, Message, Serialize, Deserialize, PartialEq, SimpleObject)]
#[eip712(
name = "VersionUpgradeMessage",
name = "UpgradeIntentMessage",
version = "0",
chain_id = 1,
verifying_contract = "0xc944e90c64b2c07662a292be6244bdf05cda44a7"
)]
pub struct VersionUpgradeMessage {
// identify through the current subgraph deployment
pub struct UpgradeIntentMessage {
/// subgraph id shared by both versions of the subgraph deployment
#[prost(string, tag = "1")]
pub identifier: String,
pub subgraph_id: String,
// new version of the subgraph has a new deployment hash
#[prost(string, tag = "2")]
pub new_hash: String,
/// subgraph id shared by both versions of the subgraph deployment
#[prost(string, tag = "6")]
pub subgraph_id: String,
/// nonce cached to check against the next incoming message
#[prost(int64, tag = "3")]
pub nonce: i64,
/// blockchain relevant to the message
#[prost(string, tag = "4")]
pub network: String,
/// estimated timestamp for the usage to switch to the new version
#[prost(int64, tag = "5")]
pub migrate_time: i64,
/// Graph account sender - expect the sender to be subgraph owner
#[prost(string, tag = "7")]
#[prost(string, tag = "4")]
pub graph_account: String,
}
9 changes: 5 additions & 4 deletions src/operator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use std::sync::Arc;
use std::thread;
use std::time::Duration;
use tokio::time::{interval, sleep, timeout};
use tracing::{debug, info, warn};
use tracing::{debug, info, trace, warn};

use graphcast_sdk::graphcast_agent::{message_typing::GraphcastMessage, GraphcastAgent};

use crate::config::Config;
use crate::db::resolver::{add_message, list_messages};
use crate::message_types::{PublicPoiMessage, SimpleMessage, VersionUpgradeMessage};
use crate::message_types::{PublicPoiMessage, SimpleMessage, UpgradeIntentMessage};
use crate::metrics::{handle_serve_metrics, ACTIVE_PEERS, CACHED_MESSAGES};
use crate::operator::radio_types::RadioPayloadMessage;
use crate::server::run_server;
Expand Down Expand Up @@ -67,6 +67,7 @@ impl RadioOperator {
thread::spawn(move || {
tokio::runtime::Runtime::new().unwrap().block_on(async {
for msg in receiver {
trace!("Radio operator recevied Waku message to process");
if let Ok(msg) = agent_ref.decode::<PublicPoiMessage>(msg.payload()).await {
if let Err(e) = add_message(&db_ref, msg).await {
warn!(
Expand All @@ -75,13 +76,13 @@ impl RadioOperator {
);
};
} else if let Ok(msg) = agent_ref
.decode::<VersionUpgradeMessage>(msg.payload())
.decode::<UpgradeIntentMessage>(msg.payload())
.await
{
if let Err(e) = add_message(&db_ref, msg).await {
warn!(
err = tracing::field::debug(&e),
"Failed to store version upgrade message"
"Failed to store upgrade intent message"
);
};
} else if let Ok(msg) = agent_ref.decode::<SimpleMessage>(msg.payload()).await {
Expand Down

0 comments on commit c682968

Please sign in to comment.