Skip to content

Commit c82809d

Browse files
committed
New ledger-map compresses blocks by default so no need to compress them here as well
1 parent 9cd11a1 commit c82809d

File tree

10 files changed

+17
-107
lines changed

10 files changed

+17
-107
lines changed

Cargo.lock

Lines changed: 4 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ ed25519-dalek = { version = "2", default-features = false, features = [
2828
"pem",
2929
] }
3030
env_logger = "0.11"
31-
flate2 = { version = "1.0", features = [
32-
"rust_backend",
33-
], default-features = false }
3431
fs-err = "2.11"
3532
hex = "0.4"
3633
hmac = "0.12"

cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ dcc-common = { path = "../common" }
2727
decent_cloud_canister = { path = "../ic-canister" }
2828
dirs.workspace = true
2929
ed25519-dalek.workspace = true
30-
flate2.workspace = true
3130
fs-err.workspace = true
3231
hex.workspace = true
3332
hmac.workspace = true

cli/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use candid::{Decode, Encode, Nat, Principal as IcPrincipal};
99
use chrono::DateTime;
1010
use dcc_common::{
1111
account_balance_get_as_string, amount_as_string, cursor_from_data, refresh_caches_from_ledger,
12-
zlib_compress, Account, CursorDirection, DccIdentity, FundsTransfer, LedgerCursor,
13-
NodeProviderProfile, UpdateProfilePayload, DATA_PULL_BYTES_BEFORE_LEN, LABEL_DC_TOKEN_TRANSFER,
12+
Account, CursorDirection, DccIdentity, FundsTransfer, LedgerCursor, NodeProviderProfile,
13+
UpdateProfilePayload, DATA_PULL_BYTES_BEFORE_LEN, LABEL_DC_TOKEN_TRANSFER,
1414
};
1515
use decent_cloud::ledger_canister_client::LedgerCanister;
1616
use decent_cloud_canister::DC_TOKEN_TRANSFER_FEE_E9S;
@@ -221,9 +221,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
221221
let np_profile: NodeProviderProfile =
222222
serde_yaml_ng::from_reader(File::open(profile_file)?)?;
223223

224-
// Compress the profile with zlib and sign it
225-
let raw_data = serde_json::to_vec(&np_profile)?;
226-
let profile_payload = zlib_compress(&raw_data)?;
224+
// Serialize the profile and sign it
225+
let profile_payload = serde_json::to_vec(&np_profile)?;
227226
let signature = dcc_ident.sign(&profile_payload)?.to_vec();
228227

229228
// Send the payload

common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ crc32fast.workspace = true
1616
data-encoding.workspace = true
1717
derp.workspace = true
1818
ed25519-dalek.workspace = true
19-
flate2.workspace = true
2019
hex.workspace = true
2120
hmac.workspace = true
2221
icrc-ledger-types.workspace = true

common/src/compression.rs

Lines changed: 0 additions & 34 deletions
This file was deleted.

common/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ pub mod account_transfers;
22
pub mod account_transfers_errors;
33
pub mod cache_balances;
44
pub mod cache_transactions;
5-
pub mod compression;
65
pub mod dcc_identity;
76
pub mod ledger_cursor;
87
pub mod ledger_refresh;
@@ -17,7 +16,6 @@ pub use account_transfers_errors::TransferError;
1716
pub use cache_balances::*;
1817
pub use cache_transactions::*;
1918
use candid::Principal;
20-
pub use compression::*;
2119
pub use dcc_identity::{slice_to_32_bytes_array, slice_to_64_bytes_array};
2220
use icrc_ledger_types::icrc1::account::Account as Icrc1Account;
2321
pub use ledger_cursor::*;

common/src/offerings.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
charge_fees_to_account_no_bump_reputation, info, reward_e9s_per_block, slice_to_32_bytes_array,
3-
zlib_decompress, DccIdentity, ED25519_SIGNATURE_LENGTH, LABEL_NP_OFFERING, LABEL_NP_REGISTER,
3+
DccIdentity, ED25519_SIGNATURE_LENGTH, LABEL_NP_OFFERING, LABEL_NP_REGISTER,
44
MAX_JSON_ZLIB_PAYLOAD_LENGTH, MAX_UID_LENGTH,
55
};
66
use candid::Principal;
@@ -155,10 +155,8 @@ pub fn do_get_matching_offerings(ledger: &LedgerMap, filters: SearchFilters) ->
155155
{
156156
let payload: UpdateOfferingPayload =
157157
serde_json::from_slice(entry.value()).expect("Failed to decode payload");
158-
let offering: NPOffering = serde_json::from_str(
159-
&zlib_decompress(&payload.offering_payload).expect("Failed to decompress"),
160-
)
161-
.expect("Failed to decode offering");
158+
let offering: NPOffering =
159+
serde_json::from_slice(&payload.offering_payload).expect("Failed to decode offering");
162160

163161
// If any filter doesn't match, skip this offering
164162
for filter in &filters {
@@ -326,7 +324,7 @@ pub fn do_get_matching_offerings(ledger: &LedgerMap, filters: SearchFilters) ->
326324
#[cfg(test)]
327325
mod tests {
328326
use super::*;
329-
use crate::{do_get_matching_offerings, info, zlib_compress, AvailableUnit, SearchFilter};
327+
use crate::{do_get_matching_offerings, info, AvailableUnit, SearchFilter};
330328
use ledger_map::LedgerMap;
331329

332330
fn log_init() {
@@ -381,7 +379,7 @@ mod tests {
381379
}],
382380
};
383381
let offering_payload = UpdateOfferingPayload {
384-
offering_payload: zlib_compress(&serde_json::to_vec(&offering).unwrap()).unwrap(),
382+
offering_payload: serde_json::to_vec(&offering).unwrap(),
385383
signature: vec![],
386384
};
387385

common/src/profiles.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
charge_fees_to_account_no_bump_reputation, info, reputation_get, reward_e9s_per_block,
3-
zlib_decompress, DccIdentity, ED25519_SIGNATURE_LENGTH, LABEL_NP_PROFILE,
4-
MAX_JSON_ZLIB_PAYLOAD_LENGTH, MAX_UID_LENGTH,
3+
DccIdentity, ED25519_SIGNATURE_LENGTH, LABEL_NP_PROFILE, MAX_JSON_ZLIB_PAYLOAD_LENGTH,
4+
MAX_UID_LENGTH,
55
};
66
use candid::Principal;
77
#[cfg(target_arch = "wasm32")]
@@ -87,10 +87,8 @@ pub fn do_node_provider_get_profile(ledger: &LedgerMap, np_uid_bytes: Vec<u8>) -
8787
Ok(profile) => {
8888
let payload: UpdateProfilePayload =
8989
serde_json::from_slice(&profile).expect("Failed to decode profile payload");
90-
let profile: NodeProviderProfile = serde_json::from_str(
91-
&zlib_decompress(&payload.profile_payload).expect("Failed to decompress profile"),
92-
)
93-
.expect("Failed to decode profile");
90+
let profile: NodeProviderProfile =
91+
serde_json::from_slice(&payload.profile_payload).expect("Failed to decode profile");
9492
let profile_with_reputation = NodeProviderProfileWithReputation {
9593
profile,
9694
reputation: reputation_get(&np_uid_bytes),

ic-canister/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ ciborium.workspace = true
1717
crc32fast.workspace = true
1818
dcc-common.workspace = true
1919
ed25519-dalek.workspace = true
20-
flate2.workspace = true
2120
hex.workspace = true
2221
ic-canister-log.workspace = true
2322
ic-cdk-timers.workspace = true

0 commit comments

Comments
 (0)