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> {
126
126
& self ,
127
127
key : & Self :: Key ,
128
128
) -> 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 {
131
130
return Ok ( ShouldWeStoreContent :: NotWithinRadius ) ;
132
131
}
133
132
if self . contains_key ( key) {
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ pub struct PaginateResult<TContentKey> {
38
38
/// Different SQL table is created for each `ContentType`, with content-id as a primary key.
39
39
/// It has a configurable capacity and it will prune data that is farthest from the `NodeId` once
40
40
/// 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.
41
44
#[ derive( Debug ) ]
42
45
pub struct IdIndexedV1Store < TContentKey : OverlayContentKey , TMetric : Metric > {
43
46
/// The configuration.
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ impl ContentStore for HistoryStorage {
39
39
key : & HistoryContentKey ,
40
40
) -> Result < ShouldWeStoreContent , ContentStoreError > {
41
41
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
+ {
43
45
Ok ( ShouldWeStoreContent :: NotWithinRadius )
44
46
} else if self . store . has_content ( & content_id) ? {
45
47
Ok ( ShouldWeStoreContent :: AlreadyStored )
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ impl ContentStore for StateStorage {
54
54
key : & StateContentKey ,
55
55
) -> Result < ShouldWeStoreContent , ContentStoreError > {
56
56
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
+ {
58
60
Ok ( ShouldWeStoreContent :: NotWithinRadius )
59
61
} else if self . store . has_content ( & content_id) ? {
60
62
Ok ( ShouldWeStoreContent :: AlreadyStored )
You can’t perform that action at this time.
0 commit comments