@@ -84,6 +84,9 @@ const MAX_GOSSIP_TRAFFIC: usize = 128_000_000 / PACKET_DATA_SIZE;
84
84
const NUM_BITS_PER_BYTE : u64 = 8 ;
85
85
const MIN_SIZE_TO_COMPRESS_GZIP : u64 = 64 ;
86
86
87
+ /// Keep the number of snapshot hashes a node publishes under MAX_PROTOCOL_PAYLOAD_SIZE
88
+ pub const MAX_SNAPSHOT_HASHES : usize = 16 ;
89
+
87
90
#[ derive( Debug , PartialEq , Eq ) ]
88
91
pub enum ClusterInfoError {
89
92
NoPeers ,
@@ -441,6 +444,14 @@ impl ClusterInfo {
441
444
}
442
445
443
446
pub fn push_snapshot_hashes ( & mut self , snapshot_hashes : Vec < ( Slot , Hash ) > ) {
447
+ if snapshot_hashes. len ( ) > MAX_SNAPSHOT_HASHES {
448
+ warn ! (
449
+ "snapshot_hashes too large, ignored: {}" ,
450
+ snapshot_hashes. len( )
451
+ ) ;
452
+ return ;
453
+ }
454
+
444
455
let now = timestamp ( ) ;
445
456
let entry = CrdsValue :: new_signed (
446
457
CrdsData :: SnapshotHash ( SnapshotHash :: new ( self . id ( ) , snapshot_hashes, now) ) ,
@@ -1059,7 +1070,7 @@ impl ClusterInfo {
1059
1070
}
1060
1071
1061
1072
/// Splits a Vec of CrdsValues into a nested Vec, trying to make sure that
1062
- /// each Vec is no larger than `PROTOCOL_PAYLOAD_SIZE `
1073
+ /// each Vec is no larger than `MAX_PROTOCOL_PAYLOAD_SIZE `
1063
1074
/// Note: some messages cannot be contained within that size so in the worst case this returns
1064
1075
/// N nested Vecs with 1 item each.
1065
1076
fn split_gossip_messages ( msgs : Vec < CrdsValue > ) -> Vec < Vec < CrdsValue > > {
0 commit comments