20
20
from hathor .consensus import ConsensusAlgorithm
21
21
from hathor .exception import HathorError , InvalidNewTransaction
22
22
from hathor .feature_activation .feature_service import FeatureService
23
- from hathor .p2p . manager import ConnectionsManager
23
+ from hathor .profiler import get_cpu_profiler
24
24
from hathor .pubsub import HathorEvents , PubSubManager
25
25
from hathor .reactor import ReactorProtocol
26
26
from hathor .transaction import BaseTransaction , Block
30
30
from hathor .wallet import BaseWallet
31
31
32
32
logger = get_logger ()
33
+ cpu = get_cpu_profiler ()
33
34
34
35
35
36
class VertexHandler :
@@ -40,7 +41,6 @@ class VertexHandler:
40
41
'_tx_storage' ,
41
42
'_verification_service' ,
42
43
'_consensus' ,
43
- '_p2p_manager' ,
44
44
'_feature_service' ,
45
45
'_pubsub' ,
46
46
'_wallet' ,
@@ -55,7 +55,6 @@ def __init__(
55
55
tx_storage : TransactionStorage ,
56
56
verification_service : VerificationService ,
57
57
consensus : ConsensusAlgorithm ,
58
- p2p_manager : ConnectionsManager ,
59
58
feature_service : FeatureService ,
60
59
pubsub : PubSubManager ,
61
60
wallet : BaseWallet | None ,
@@ -67,27 +66,25 @@ def __init__(
67
66
self ._tx_storage = tx_storage
68
67
self ._verification_service = verification_service
69
68
self ._consensus = consensus
70
- self ._p2p_manager = p2p_manager
71
69
self ._feature_service = feature_service
72
70
self ._pubsub = pubsub
73
71
self ._wallet = wallet
74
72
self ._log_vertex_bytes = log_vertex_bytes
75
73
74
+ @cpu .profiler ('on_new_vertex' )
76
75
def on_new_vertex (
77
76
self ,
78
77
vertex : BaseTransaction ,
79
78
* ,
80
79
quiet : bool = False ,
81
80
fails_silently : bool = True ,
82
- propagate_to_peers : bool = True ,
83
81
reject_locked_reward : bool = True ,
84
82
) -> bool :
85
83
""" New method for adding transactions or blocks that steps the validation state machine.
86
84
87
85
:param vertex: transaction to be added
88
86
:param quiet: if True will not log when a new tx is accepted
89
87
:param fails_silently: if False will raise an exception when tx cannot be added
90
- :param propagate_to_peers: if True will relay the tx to other peers if it is accepted
91
88
"""
92
89
is_valid = self ._validate_vertex (
93
90
vertex ,
@@ -102,7 +99,6 @@ def on_new_vertex(
102
99
self ._post_consensus (
103
100
vertex ,
104
101
quiet = quiet ,
105
- propagate_to_peers = propagate_to_peers ,
106
102
reject_locked_reward = reject_locked_reward
107
103
)
108
104
@@ -177,7 +173,6 @@ def _post_consensus(
177
173
vertex : BaseTransaction ,
178
174
* ,
179
175
quiet : bool ,
180
- propagate_to_peers : bool ,
181
176
reject_locked_reward : bool ,
182
177
) -> None :
183
178
""" Handle operations that need to happen once the tx becomes fully validated.
@@ -208,10 +203,6 @@ def _post_consensus(
208
203
209
204
self ._log_new_object (vertex , 'new {}' , quiet = quiet )
210
205
211
- if propagate_to_peers :
212
- # Propagate to our peers.
213
- self ._p2p_manager .send_tx_to_peers (vertex )
214
-
215
206
def _log_new_object (self , tx : BaseTransaction , message_fmt : str , * , quiet : bool ) -> None :
216
207
""" A shortcut for logging additional information for block/txs.
217
208
"""
0 commit comments