66from attrs import frozen
77from py_flare_common .ftso .median import FtsoMedian
88
9+ from configuration .config import Protocol
910from observer .fast_updates_manager import FastUpdatesManager
1011from observer .message import Message , MessageLevel
1112from observer .reward_epoch_manager import Entity
@@ -30,6 +31,12 @@ class MinimalConditions:
3031
3132 time_period : Interval = Interval .LAST_2_HOURS
3233
34+ network : int | None = None
35+
36+ def for_network (self , network : int ) -> Self :
37+ self .network = network
38+ return self
39+
3340 def for_reward_epoch (self , rid : int ) -> Self :
3441 self .reward_epoch_id = rid
3542 return self
@@ -41,7 +48,7 @@ def set_time_interval(self, interval: Interval) -> Self:
4148 def calculate_ftso_anchor_feeds (
4249 self , medians : deque [list [FtsoMedian ]], votes : deque [list [int | None ]]
4350 ) -> Sequence [Message ]:
44- mb = Message .builder ()
51+ mb = Message .builder (). add ( network = self . network , protocol = Protocol . FTSO )
4552 messages = []
4653
4754 total , total_hit = 0 , 0
@@ -86,7 +93,7 @@ def calculate_ftso_anchor_feeds(
8693 def calculate_ftso_block_latency_feeds (
8794 self , entity : Entity , spm : SigningPolicyManager , fum : FastUpdatesManager
8895 ) -> Sequence [Message ]:
89- mb = Message .builder ()
96+ mb = Message .builder (). add ( network = self . network , protocol = Protocol . FAST_UPDATES )
9097 messages = []
9198 previous_total_active_weight = sum (
9299 [e .normalized_weight for e in spm .previous_policy .entities ]
@@ -168,7 +175,7 @@ def calculate_ftso_block_latency_feeds(
168175 def calculate_staking (
169176 self , uptime_checks : int , node_connections : dict [str , deque ]
170177 ) -> Sequence [Message ]:
171- mb = Message .builder ()
178+ mb = Message .builder (). add ( network = self . network , protocol = Protocol . STAKING )
172179 messages = []
173180 for node in node_connections :
174181 if (
@@ -188,7 +195,7 @@ def calculate_staking(
188195 return messages
189196
190197 def calculate_fdc_participation (self , signatures : deque [bool ]) -> Sequence [Message ]:
191- mb = Message .builder ()
198+ mb = Message .builder (). add ( network = self . network , protocol = Protocol . FDC )
192199 messages = []
193200 if (
194201 len (signatures ) > 0
0 commit comments