File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed
crates/ethportal-api/src/types/content_key Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ impl fmt::Display for BeaconContentKey {
113
113
}
114
114
115
115
impl OverlayContentKey for BeaconContentKey {
116
+ fn affected_by_radius ( & self ) -> bool {
117
+ false
118
+ }
119
+
116
120
fn to_bytes ( & self ) -> RawContentKey {
117
121
let mut bytes;
118
122
Original file line number Diff line number Diff line change @@ -216,6 +216,17 @@ impl fmt::Display for HistoryContentKey {
216
216
}
217
217
218
218
impl OverlayContentKey for HistoryContentKey {
219
+ fn affected_by_radius ( & self ) -> bool {
220
+ match self {
221
+ Self :: BlockHeaderByHash ( _) => true ,
222
+ Self :: BlockHeaderByNumber ( _) => true ,
223
+ Self :: BlockBody ( _) => true ,
224
+ Self :: BlockReceipts ( _) => true ,
225
+ Self :: EphemeralHeadersFindContent ( _) => false ,
226
+ Self :: EphemeralHeaderOffer ( _) => false ,
227
+ }
228
+ }
229
+
219
230
fn to_bytes ( & self ) -> RawContentKey {
220
231
let mut bytes;
221
232
Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ pub trait OverlayContentKey:
21
21
Sha256 :: digest ( self . to_bytes ( ) ) . into ( )
22
22
}
23
23
24
+ /// Returns whether this content key is affected by radius.
25
+ ///
26
+ /// Most of the content is supposted to be stored if it falls within node's radius, but some
27
+ /// content is not dependant on the radius and uses different logic instead.
28
+ fn affected_by_radius ( & self ) -> bool ;
29
+
24
30
/// Returns the bytes of the content key.
25
31
///
26
32
/// The [RawContentKey] is better suited than `Vec<u8>` for representing content key bytes.
@@ -96,6 +102,10 @@ impl Deref for IdentityContentKey {
96
102
}
97
103
98
104
impl OverlayContentKey for IdentityContentKey {
105
+ fn affected_by_radius ( & self ) -> bool {
106
+ true
107
+ }
108
+
99
109
fn content_id ( & self ) -> [ u8 ; 32 ] {
100
110
self . value
101
111
}
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ pub struct ContractBytecodeKey {
65
65
}
66
66
67
67
impl OverlayContentKey for StateContentKey {
68
+ fn affected_by_radius ( & self ) -> bool {
69
+ true
70
+ }
71
+
68
72
fn to_bytes ( & self ) -> RawContentKey {
69
73
let mut bytes;
70
74
You can’t perform that action at this time.
0 commit comments