Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hathor/feature_activation/bit_signaling_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def __init__(
self._validate_support_intersection()

def start(self) -> None:
"""
Log information related to bit signaling. Must be called after the storage is ready and migrations have
been applied.
"""
best_block = self._tx_storage.get_best_block()

self._warn_non_signaling_features(best_block)
Expand Down
4 changes: 2 additions & 2 deletions hathor/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ def start(self) -> None:
if self._enable_event_queue:
self._event_manager.start(not_none(self.my_peer.id))

self._bit_signaling_service.start()

self.state = self.NodeState.INITIALIZING
self.pubsub.publish(HathorEvents.MANAGER_ON_START)
self._event_manager.load_started()
Expand Down Expand Up @@ -546,6 +544,8 @@ def _initialize_components_new(self) -> None:
self.tx_storage.pre_init()
assert self.tx_storage.indexes is not None

self._bit_signaling_service.start()

started_at = int(time.time())
last_started_at = self.tx_storage.get_last_started_at()
if last_started_at >= started_at:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Hathor Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

from structlog import get_logger

from hathor.transaction.storage.migrations import BaseMigration
from hathor.util import progress

if TYPE_CHECKING:
from hathor.transaction.storage import TransactionStorage

logger = get_logger()


class Migration(BaseMigration):
def skip_empty_db(self) -> bool:
return True

def get_db_name(self) -> str:
return 'add_feature_activation_bit_counts_metadata'

def run(self, storage: 'TransactionStorage') -> None:
log = logger.new()
topological_iterator = storage.topological_iterator()

for vertex in progress(topological_iterator, log=log, total=None):
if vertex.is_block:
vertex.update_initial_metadata()
8 changes: 7 additions & 1 deletion hathor/transaction/storage/transaction_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
TransactionIsNotABlock,
TransactionNotInAllowedScopeError,
)
from hathor.transaction.storage.migrations import BaseMigration, MigrationState, add_min_height_metadata
from hathor.transaction.storage.migrations import (
BaseMigration,
MigrationState,
add_feature_activation_bit_counts_metadata,
add_min_height_metadata,
)
from hathor.transaction.storage.tx_allow_scope import TxAllowScope, tx_allow_context
from hathor.transaction.transaction import Transaction
from hathor.transaction.transaction_metadata import TransactionMetadata
Expand Down Expand Up @@ -81,6 +86,7 @@ class TransactionStorage(ABC):
# history of migrations that have to be applied in the order defined here
_migration_factories: list[type[BaseMigration]] = [
add_min_height_metadata.Migration,
add_feature_activation_bit_counts_metadata.Migration,
]

_migrations: list[BaseMigration]
Expand Down