@@ -123,7 +123,7 @@ def __init__(self,
123
123
'Either enable it, or use the reset-event-queue CLI command to remove all event-related data'
124
124
)
125
125
126
- self .settings = settings
126
+ self ._settings = settings
127
127
self ._cmd_path : Optional [str ] = None
128
128
129
129
self .log = logger .new ()
@@ -228,10 +228,11 @@ def __init__(self,
228
228
self .lc_check_sync_state_interval = self .CHECK_SYNC_STATE_INTERVAL
229
229
230
230
def get_default_capabilities (self ) -> list [str ]:
231
+ """Return the default capabilities for this manager."""
231
232
return [
232
- self .settings .CAPABILITY_WHITELIST ,
233
- self .settings .CAPABILITY_SYNC_VERSION ,
234
- self .settings .CAPABILITY_GET_BEST_BLOCKCHAIN
233
+ self ._settings .CAPABILITY_WHITELIST ,
234
+ self ._settings .CAPABILITY_SYNC_VERSION ,
235
+ self ._settings .CAPABILITY_GET_BEST_BLOCKCHAIN
235
236
]
236
237
237
238
def start (self ) -> None :
@@ -444,7 +445,7 @@ def _initialize_components_full_verification(self) -> None:
444
445
# It's safe to skip block weight verification during initialization because
445
446
# we trust the difficulty stored in metadata
446
447
skip_block_weight_verification = True
447
- if block_count % self .settings .VERIFY_WEIGHT_EVERY_N_BLOCKS == 0 :
448
+ if block_count % self ._settings .VERIFY_WEIGHT_EVERY_N_BLOCKS == 0 :
448
449
skip_block_weight_verification = False
449
450
450
451
try :
@@ -629,14 +630,14 @@ def _verify_soft_voided_txs(self) -> None:
629
630
soft_voided_meta = soft_voided_tx .get_metadata ()
630
631
voided_set = soft_voided_meta .voided_by or set ()
631
632
# If the tx is not marked as soft voided, then we can't continue the initialization
632
- if self .settings .SOFT_VOIDED_ID not in voided_set :
633
+ if self ._settings .SOFT_VOIDED_ID not in voided_set :
633
634
self .log .error (
634
635
'Error initializing node. Your database is not compatible with the current version of the'
635
636
' full node. You must use the latest available snapshot or sync from the beginning.'
636
637
)
637
638
sys .exit (- 1 )
638
639
639
- assert {soft_voided_id , self .settings .SOFT_VOIDED_ID }.issubset (voided_set )
640
+ assert {soft_voided_id , self ._settings .SOFT_VOIDED_ID }.issubset (voided_set )
640
641
641
642
def _verify_checkpoints (self ) -> None :
642
643
""" Method to verify if all checkpoints that exist in the database have the correct hash and are winners.
@@ -775,7 +776,7 @@ def make_block_template(self, parent_block_hash: VertexId, timestamp: Optional[i
775
776
"""
776
777
parent_block = self .tx_storage .get_transaction (parent_block_hash )
777
778
assert isinstance (parent_block , Block )
778
- parent_txs = self .generate_parent_txs (parent_block .timestamp + self .settings .MAX_DISTANCE_BETWEEN_BLOCKS )
779
+ parent_txs = self .generate_parent_txs (parent_block .timestamp + self ._settings .MAX_DISTANCE_BETWEEN_BLOCKS )
779
780
if timestamp is None :
780
781
current_timestamp = int (max (self .tx_storage .latest_timestamp , self .reactor .seconds ()))
781
782
else :
@@ -811,7 +812,7 @@ def _make_block_template(self, parent_block: Block, parent_txs: 'ParentTxs', cur
811
812
timestamp_abs_min = parent_block .timestamp + 1
812
813
# and absolute maximum limited by max time between blocks
813
814
if not parent_block .is_genesis :
814
- timestamp_abs_max = parent_block .timestamp + self .settings .MAX_DISTANCE_BETWEEN_BLOCKS - 1
815
+ timestamp_abs_max = parent_block .timestamp + self ._settings .MAX_DISTANCE_BETWEEN_BLOCKS - 1
815
816
else :
816
817
timestamp_abs_max = 0xffffffff
817
818
assert timestamp_abs_max > timestamp_abs_min
@@ -820,12 +821,12 @@ def _make_block_template(self, parent_block: Block, parent_txs: 'ParentTxs', cur
820
821
timestamp_min = max (timestamp_abs_min , parent_txs .max_timestamp + 1 )
821
822
assert timestamp_min <= timestamp_abs_max
822
823
# when we have weight decay, the max timestamp will be when the next decay happens
823
- if with_weight_decay and self .settings .WEIGHT_DECAY_ENABLED :
824
+ if with_weight_decay and self ._settings .WEIGHT_DECAY_ENABLED :
824
825
# we either have passed the first decay or not, the range will vary depending on that
825
- if timestamp_min > timestamp_abs_min + self .settings .WEIGHT_DECAY_ACTIVATE_DISTANCE :
826
- timestamp_max_decay = timestamp_min + self .settings .WEIGHT_DECAY_WINDOW_SIZE
826
+ if timestamp_min > timestamp_abs_min + self ._settings .WEIGHT_DECAY_ACTIVATE_DISTANCE :
827
+ timestamp_max_decay = timestamp_min + self ._settings .WEIGHT_DECAY_WINDOW_SIZE
827
828
else :
828
- timestamp_max_decay = timestamp_abs_min + self .settings .WEIGHT_DECAY_ACTIVATE_DISTANCE
829
+ timestamp_max_decay = timestamp_abs_min + self ._settings .WEIGHT_DECAY_ACTIVATE_DISTANCE
829
830
timestamp_max = min (timestamp_abs_max , timestamp_max_decay )
830
831
else :
831
832
timestamp_max = timestamp_abs_max
@@ -836,7 +837,7 @@ def _make_block_template(self, parent_block: Block, parent_txs: 'ParentTxs', cur
836
837
# protect agains a weight that is too small but using WEIGHT_TOL instead of 2*WEIGHT_TOL)
837
838
min_significant_weight = calculate_min_significant_weight (
838
839
parent_block_metadata .score ,
839
- 2 * self .settings .WEIGHT_TOL
840
+ 2 * self ._settings .WEIGHT_TOL
840
841
)
841
842
weight = max (daa .calculate_next_weight (parent_block , timestamp ), min_significant_weight )
842
843
height = parent_block .get_height () + 1
@@ -904,7 +905,7 @@ def submit_block(self, blk: Block, fails_silently: bool = True) -> bool:
904
905
# this is the smallest weight that won't cause the score to increase, anything equal or smaller is bad
905
906
min_insignificant_weight = calculate_min_significant_weight (
906
907
parent_block_metadata .score ,
907
- self .settings .WEIGHT_TOL
908
+ self ._settings .WEIGHT_TOL
908
909
)
909
910
if blk .weight <= min_insignificant_weight :
910
911
self .log .warn ('submit_block(): insignificant weight? accepted anyway' , blk = blk .hash_hex , weight = blk .weight )
@@ -915,7 +916,7 @@ def push_tx(self, tx: Transaction, allow_non_standard_script: bool = False,
915
916
"""Used by all APIs that accept a new transaction (like push_tx)
916
917
"""
917
918
if max_output_script_size is None :
918
- max_output_script_size = self .settings .PUSHTX_MAX_OUTPUT_SCRIPT_SIZE
919
+ max_output_script_size = self ._settings .PUSHTX_MAX_OUTPUT_SCRIPT_SIZE
919
920
920
921
is_double_spending = tx .is_double_spending ()
921
922
if is_double_spending :
@@ -978,7 +979,7 @@ def on_new_tx(self, tx: BaseTransaction, *, conn: Optional[HathorProtocol] = Non
978
979
self .tx_storage .compare_bytes_with_local_tx (tx )
979
980
already_exists = True
980
981
981
- if tx .timestamp - self .reactor .seconds () > self .settings .MAX_FUTURE_TIMESTAMP_ALLOWED :
982
+ if tx .timestamp - self .reactor .seconds () > self ._settings .MAX_FUTURE_TIMESTAMP_ALLOWED :
982
983
if not fails_silently :
983
984
raise InvalidNewTransaction ('Ignoring transaction in the future {} (timestamp={})' .format (
984
985
tx .hash_hex , tx .timestamp ))
@@ -1127,7 +1128,7 @@ def tx_fully_validated(self, tx: BaseTransaction, *, quiet: bool) -> None:
1127
1128
1128
1129
def _log_feature_states (self , vertex : BaseTransaction ) -> None :
1129
1130
"""Log features states for a block. Used as part of the Feature Activation Phased Testing."""
1130
- if not self .settings .FEATURE_ACTIVATION .enable_usage or not isinstance (vertex , Block ):
1131
+ if not self ._settings .FEATURE_ACTIVATION .enable_usage or not isinstance (vertex , Block ):
1131
1132
return
1132
1133
1133
1134
feature_descriptions = self ._feature_service .get_bits_description (block = vertex )
@@ -1163,10 +1164,10 @@ def listen(self, description: str, use_ssl: Optional[bool] = None) -> None:
1163
1164
self .my_peer .entrypoints .append (address )
1164
1165
1165
1166
def has_sync_version_capability (self ) -> bool :
1166
- return self .settings .CAPABILITY_SYNC_VERSION in self .capabilities
1167
+ return self ._settings .CAPABILITY_SYNC_VERSION in self .capabilities
1167
1168
1168
1169
def add_peer_to_whitelist (self , peer_id ):
1169
- if not self .settings .ENABLE_PEER_WHITELIST :
1170
+ if not self ._settings .ENABLE_PEER_WHITELIST :
1170
1171
return
1171
1172
1172
1173
if peer_id in self .peers_whitelist :
@@ -1175,7 +1176,7 @@ def add_peer_to_whitelist(self, peer_id):
1175
1176
self .peers_whitelist .append (peer_id )
1176
1177
1177
1178
def remove_peer_from_whitelist_and_disconnect (self , peer_id : str ) -> None :
1178
- if not self .settings .ENABLE_PEER_WHITELIST :
1179
+ if not self ._settings .ENABLE_PEER_WHITELIST :
1179
1180
return
1180
1181
1181
1182
if peer_id in self .peers_whitelist :
@@ -1190,7 +1191,7 @@ def has_recent_activity(self) -> bool:
1190
1191
# We use the avg time between blocks as a basis to know how much time we should use to consider the fullnode
1191
1192
# as not synced.
1192
1193
maximum_timestamp_delta = (
1193
- self .settings .P2P_RECENT_ACTIVITY_THRESHOLD_MULTIPLIER * self .settings .AVG_TIME_BETWEEN_BLOCKS
1194
+ self ._settings .P2P_RECENT_ACTIVITY_THRESHOLD_MULTIPLIER * self ._settings .AVG_TIME_BETWEEN_BLOCKS
1194
1195
)
1195
1196
1196
1197
if current_timestamp - latest_blockchain_timestamp > maximum_timestamp_delta :
0 commit comments