From 7d0ef9cf377e9d8e8ca75aef5d9889d802583c87 Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 2 Sep 2024 08:37:59 +1000 Subject: [PATCH] DO NOT MERGE: Add some fake objects at the start of the stream --- crates/sc-consensus-subspace-rpc/src/lib.rs | 17 +++++++++++++++-- crates/subspace-core-primitives/src/objects.rs | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/sc-consensus-subspace-rpc/src/lib.rs b/crates/sc-consensus-subspace-rpc/src/lib.rs index b88e8ce3e29..92c7c8b7f9a 100644 --- a/crates/sc-consensus-subspace-rpc/src/lib.rs +++ b/crates/sc-consensus-subspace-rpc/src/lib.rs @@ -58,7 +58,7 @@ use std::sync::{Arc, Weak}; use std::time::Duration; use subspace_archiving::archiver::NewArchivedSegment; use subspace_core_primitives::crypto::kzg::Kzg; -use subspace_core_primitives::objects::GlobalObjectMapping; +use subspace_core_primitives::objects::{GlobalObject, GlobalObjectMapping}; use subspace_core_primitives::{ Blake3Hash, Blake3HashHex, BlockHash, HistorySize, Piece, PieceIndex, PublicKey, SegmentHeader, SegmentIndex, SlotNumber, Solution, @@ -893,6 +893,13 @@ where .ready_chunks(OBJECT_MAPPING_BATCH_SIZE) .map(|objects| GlobalObjectMapping::V0 { objects }); + // TESTING ONLY, DO NOT MERGE + let fake_mapping = vec![GlobalObject::default(); 3]; + let mapping_stream = stream::iter(fake_mapping) + .ready_chunks(OBJECT_MAPPING_BATCH_SIZE) + .map(|objects| GlobalObjectMapping::V0 { objects }) + .chain(mapping_stream); + self.subscription_executor.spawn( "subspace-archived-object-mappings-subscription", Some("rpc"), @@ -940,7 +947,13 @@ where .flat_map(move |archived_segment_notification| { let objects = archived_segment_notification .archived_segment - .global_object_mappings() + .global_object_mappings(); + + // TESTING ONLY, DO NOT MERGE + let fake_mapping = vec![GlobalObject::default(); 3]; + let objects = objects.chain(fake_mapping); + + let objects = objects .filter(|object| hashes.remove(&object.hash)) .collect::>(); diff --git a/crates/subspace-core-primitives/src/objects.rs b/crates/subspace-core-primitives/src/objects.rs index 39bd62caf43..8ac0498cdfb 100644 --- a/crates/subspace-core-primitives/src/objects.rs +++ b/crates/subspace-core-primitives/src/objects.rs @@ -128,7 +128,9 @@ pub struct PieceObjectMapping { } /// Object stored in the history of the blockchain -#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Encode, Decode, TypeInfo)] +#[derive( + Default, Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Encode, Decode, TypeInfo, +)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr( feature = "serde",