Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into map/2-phase-commit-mo…
Browse files Browse the repository at this point in the history
…bile-pv
  • Loading branch information
maplant committed Jan 17, 2024
2 parents 3d1833f + 9e076d1 commit 51313ac
Show file tree
Hide file tree
Showing 53 changed files with 3,522 additions and 1,084 deletions.
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ rust_decimal_macros = "1"
base64 = ">=0.21"
sha2 = "0.10"
tonic = {version = "0", features = ["tls", "tls-roots"]}
http = "0"
http = "<=0.2"
triggered = "0"
futures = "*"
futures-util = "*"
Expand Down
10 changes: 9 additions & 1 deletion file_store/src/cli/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Cmd {
"operation_mode": msg.report.operation_mode,
"location_validation_timestamp": msg.report.location_validation_timestamp,
});
// print_json(&msg)?;
print_json(&json)?;
}
FileType::CellSpeedtest => {
Expand Down Expand Up @@ -204,7 +205,6 @@ impl Cmd {
print_json(&json!({
"cbsd_id": heartbeat.cbsd_id,
"pub_key": PublicKey::try_from(heartbeat.pub_key)?,
"reward_multiplier": heartbeat.reward_multiplier,
"timestamp": heartbeat.timestamp,
"cell_type": heartbeat.cell_type,
"validity": heartbeat.validity,
Expand All @@ -226,6 +226,14 @@ impl Cmd {
"subscriber_id": reward.subscriber_id,
"discovery_location_amount": reward.discovery_location_amount,
}))?,
Some(Reward::ServiceProviderReward(reward)) => print_json(&json!({
"service_provider": reward.service_provider_id,
"amount": reward.amount,
}))?,
Some(Reward::UnallocatedReward(reward)) => print_json(&json!({
"unallocated_reward_type": reward.reward_type,
"amount": reward.amount,
}))?,
_ => (),
}
}
Expand Down
6 changes: 3 additions & 3 deletions file_store/src/file_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ impl FileSinkBuilder {

#[derive(Debug, Clone)]
pub struct FileSinkClient {
sender: MessageSender,
metric: &'static str,
pub sender: MessageSender,
pub metric: &'static str,
}

const OK_LABEL: Label = Label::from_static_parts("status", "ok");
Expand Down Expand Up @@ -536,7 +536,7 @@ impl FileSink {
}
}

fn file_name(path_buf: &Path) -> Result<String> {
pub fn file_name(path_buf: &Path) -> Result<String> {
path_buf
.file_name()
.map(|os_str| os_str.to_string_lossy().to_string())
Expand Down
2 changes: 0 additions & 2 deletions file_store/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pub mod cli {
pub struct ValidatedHeartbeat {
pub cbsd_id: String,
pub pub_key: PublicKeyBinary,
pub reward_multiplier: f32,
pub timestamp: DateTime<Utc>,
pub cell_type: CellType,
pub validity: HeartbeatValidity,
Expand All @@ -113,7 +112,6 @@ pub mod cli {
Ok(Self {
cbsd_id: v.cbsd_id.clone(),
pub_key: v.pub_key.clone().into(),
reward_multiplier: v.reward_multiplier,
timestamp: Utc
.timestamp_opt(v.timestamp as i64, 0)
.single()
Expand Down
2 changes: 2 additions & 0 deletions file_store/src/traits/msg_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl_msg_verify!(mobile_config::AuthorizationListReqV1, signature);
impl_msg_verify!(mobile_config::AuthorizationListResV1, signature);
impl_msg_verify!(mobile_config::EntityVerifyReqV1, signature);
impl_msg_verify!(mobile_config::EntityVerifyResV1, signature);
impl_msg_verify!(mobile_config::CarrierKeyToEntityReqV1, signature);
impl_msg_verify!(mobile_config::CarrierKeyToEntityResV1, signature);
impl_msg_verify!(mobile_config::GatewayInfoReqV1, signature);
impl_msg_verify!(mobile_config::GatewayInfoStreamReqV1, signature);
impl_msg_verify!(mobile_config::GatewayInfoResV1, signature);
Expand Down
2 changes: 1 addition & 1 deletion iot_config/src/route_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl iot_config::Route for RouteService {
self.verify_stream_request_signature(&signer, &request)?;

let since = Utc
.timestamp_millis_opt(request.since as i64)
.timestamp_opt(request.since as i64, 0)
.single()
.ok_or_else(|| Status::invalid_argument("unable to parse since timestamp"))?;

Expand Down
18 changes: 9 additions & 9 deletions iot_config/tests/route_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ async fn stream_only_sends_data_modified_since(pool: Pool<Postgres>) {
)
.await;

tokio::time::sleep(std::time::Duration::from_millis(1)).await;
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let since = Utc::now();
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

let route2 = create_route(&mut client, &org, &admin_keypair).await;

Expand All @@ -195,7 +195,7 @@ async fn stream_only_sends_data_modified_since(pool: Pool<Postgres>) {
let response = client
.stream(route_stream_req_v1(
&client_keypair,
since.timestamp_millis() as u64,
since.timestamp() as u64,
))
.await
.expect("stream request");
Expand Down Expand Up @@ -331,7 +331,7 @@ where

fn route_stream_req_v1(signer: &Keypair, since: u64) -> RouteStreamReqV1 {
let mut request = RouteStreamReqV1 {
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signer: signer.public_key().to_vec(),
since,
signature: vec![],
Expand Down Expand Up @@ -408,7 +408,7 @@ async fn create_org(port: u64, admin_keypair: &Keypair) -> proto::OrgResV1 {
owner: generate_keypair().public_key().to_vec(),
payer: generate_keypair().public_key().to_vec(),
devaddrs: 8,
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signature: vec![],
delegate_keys: vec![],
signer: admin_keypair.public_key().into(),
Expand Down Expand Up @@ -455,7 +455,7 @@ async fn create_route(
locked: false,
ignore_empty_skf: true,
}),
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signature: vec![],
signer: signing_keypair.public_key().into(),
};
Expand Down Expand Up @@ -493,7 +493,7 @@ async fn create_euis(
let mut request = proto::RouteUpdateEuisReqV1 {
action: proto::ActionV1::Add as i32,
eui_pair: Some(pair),
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signature: vec![],
signer: signing_keypair.public_key().into(),
};
Expand Down Expand Up @@ -528,7 +528,7 @@ async fn create_devaddr_ranges(
let mut request = proto::RouteUpdateDevaddrRangesReqV1 {
action: proto::ActionV1::Add as i32,
devaddr_range: Some(range),
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signature: vec![],
signer: signing_keypair.public_key().into(),
};
Expand Down Expand Up @@ -570,7 +570,7 @@ async fn create_skf(
let mut request = proto::RouteSkfUpdateReqV1 {
route_id: route.id.clone(),
updates,
timestamp: Utc::now().timestamp_millis() as u64,
timestamp: Utc::now().timestamp() as u64,
signature: vec![],
signer: signing_keypair.public_key().into(),
};
Expand Down
Loading

0 comments on commit 51313ac

Please sign in to comment.