Skip to content

Commit fd14779

Browse files
SmaGManRexagon
authored andcommitted
fix(collator): update has_externals on initial anchors import
1 parent 91b3996 commit fd14779

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

collator/src/collator/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ impl CollatorStdImpl {
10651065
let mut last_anchor = None;
10661066
let mut all_anchors_are_taken_from_cache = false;
10671067
let mut processed_to_anchor_exists_in_cache = false;
1068+
let mut total_our_exts_count: usize = 0;
10681069

10691070
// we count our messages for processed_to with existing offset
10701071
let mut offset = processed_to_msgs_offset as usize;
@@ -1100,6 +1101,7 @@ impl CollatorStdImpl {
11001101

11011102
// and keep others
11021103
let our_exts_count = anchor.count_externals_for(&shard_id, offset);
1104+
total_our_exts_count = total_our_exts_count.saturating_add(our_exts_count);
11031105
anchors_info.push(InitAnchorSource::FromCache(AnchorInfo::from_anchor(
11041106
anchor.clone(),
11051107
our_exts_count,
@@ -1122,6 +1124,7 @@ impl CollatorStdImpl {
11221124
)));
11231125
};
11241126
anchors_cache.set_last_imported_anchor_info(anchor_info.clone());
1127+
anchors_cache.set_has_pending_externals(total_our_exts_count > 0);
11251128

11261129
return Ok(anchors_info);
11271130
}
@@ -1159,6 +1162,7 @@ impl CollatorStdImpl {
11591162
// add loaded anchor to cache
11601163
if let Some(anchor) = next_anchor {
11611164
let our_exts_count = anchor.count_externals_for(&shard_id, offset);
1165+
total_our_exts_count = total_our_exts_count.saturating_add(our_exts_count);
11621166
anchors_cache.insert(anchor.clone(), our_exts_count);
11631167
anchors_info.push(InitAnchorSource::Imported(AnchorInfo::from_anchor(
11641168
anchor,
@@ -1193,6 +1197,8 @@ impl CollatorStdImpl {
11931197
next_anchor = Some(anchor);
11941198
}
11951199

1200+
anchors_cache.set_has_pending_externals(total_our_exts_count > 0);
1201+
11961202
Ok(anchors_info)
11971203
}
11981204

collator/src/collator/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ impl AnchorsCache {
12481248
pub fn clear(&mut self) {
12491249
self.cache.clear();
12501250
self.last_imported_anchor = None;
1251+
self.has_pending_externals = false;
12511252
}
12521253

12531254
pub fn len(&self) -> usize {

0 commit comments

Comments
 (0)