File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,7 @@ impl<TMetric: Metric> ContentStore for MemoryContentStore<TMetric> {
126126 & self ,
127127 key : & Self :: Key ,
128128 ) -> Result < ShouldWeStoreContent , ContentStoreError > {
129- let distance = self . distance_to_key ( key) ;
130- if distance > self . radius {
129+ if key. affected_by_radius ( ) && self . distance_to_key ( key) > self . radius {
131130 return Ok ( ShouldWeStoreContent :: NotWithinRadius ) ;
132131 }
133132 if self . contains_key ( key) {
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ pub struct PaginateResult<TContentKey> {
3838/// Different SQL table is created for each `ContentType`, with content-id as a primary key.
3939/// It has a configurable capacity and it will prune data that is farthest from the `NodeId` once
4040/// it uses more than storage capacity.
41+ ///
42+ /// Only content that is affected by radius should be stored in this store, otherwise it might be
43+ /// removed as the radius shrinks because of the pruning.
4144#[ derive( Debug ) ]
4245pub struct IdIndexedV1Store < TContentKey : OverlayContentKey , TMetric : Metric > {
4346 /// The configuration.
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ impl ContentStore for HistoryStorage {
3939 key : & HistoryContentKey ,
4040 ) -> Result < ShouldWeStoreContent , ContentStoreError > {
4141 let content_id = ContentId :: from ( key. content_id ( ) ) ;
42- if self . store . distance_to_content_id ( & content_id) > self . store . radius ( ) {
42+ if key. affected_by_radius ( )
43+ && self . store . distance_to_content_id ( & content_id) > self . store . radius ( )
44+ {
4345 Ok ( ShouldWeStoreContent :: NotWithinRadius )
4446 } else if self . store . has_content ( & content_id) ? {
4547 Ok ( ShouldWeStoreContent :: AlreadyStored )
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ impl ContentStore for StateStorage {
5454 key : & StateContentKey ,
5555 ) -> Result < ShouldWeStoreContent , ContentStoreError > {
5656 let content_id = ContentId :: from ( key. content_id ( ) ) ;
57- if self . store . distance_to_content_id ( & content_id) > self . store . radius ( ) {
57+ if key. affected_by_radius ( )
58+ && self . store . distance_to_content_id ( & content_id) > self . store . radius ( )
59+ {
5860 Ok ( ShouldWeStoreContent :: NotWithinRadius )
5961 } else if self . store . has_content ( & content_id) ? {
6062 Ok ( ShouldWeStoreContent :: AlreadyStored )
You can’t perform that action at this time.
0 commit comments