Skip to content

Commit 78d2895

Browse files
committed
relayer: remove RelayV2 init code
1 parent aa31df1 commit 78d2895

File tree

3 files changed

+6
-52
lines changed

3 files changed

+6
-52
lines changed

light-client-bin/src/subcmds.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,11 @@ impl RunConfig {
6969
BAD_MESSAGE_ALLOWED_EACH_HOUR,
7070
));
7171
let sync_protocol = SyncProtocol::new(storage.clone(), Arc::clone(&peers));
72-
let relay_protocol_v2 = RelayProtocol::new(
72+
let relay_protocol = RelayProtocol::new(
7373
pending_txs.clone(),
7474
Arc::clone(&peers),
7575
consensus.clone(),
7676
storage.clone(),
77-
false,
78-
);
79-
let relay_protocol_v3 = RelayProtocol::new(
80-
pending_txs.clone(),
81-
Arc::clone(&peers),
82-
consensus.clone(),
83-
storage.clone(),
84-
true,
8577
);
8678
let light_client: Box<dyn CKBProtocolHandler> = Box::new(LightClientProtocol::new(
8779
storage.clone(),
@@ -96,14 +88,9 @@ impl RunConfig {
9688
Box::new(sync_protocol),
9789
Arc::clone(&network_state),
9890
),
99-
CKBProtocol::new_with_support_protocol(
100-
SupportProtocols::RelayV2,
101-
Box::new(relay_protocol_v2),
102-
Arc::clone(&network_state),
103-
),
10491
CKBProtocol::new_with_support_protocol(
10592
SupportProtocols::RelayV3,
106-
Box::new(relay_protocol_v3),
93+
Box::new(relay_protocol),
10794
Arc::clone(&network_state),
10895
),
10996
CKBProtocol::new_with_support_protocol(

light-client-lib/src/protocols/relayer.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub struct RelayProtocol {
2929

3030
consensus: Consensus,
3131
storage: Storage,
32-
v3: bool,
3332
}
3433

3534
// a simple struct to store the pending transactions in memory with size limit
@@ -94,15 +93,13 @@ impl RelayProtocol {
9493
connected_peers: Arc<Peers>,
9594
consensus: Consensus,
9695
storage: Storage,
97-
v3: bool,
9896
) -> Self {
9997
Self {
10098
opened_peers: HashMap::new(),
10199
pending_txs,
102100
connected_peers,
103101
consensus,
104102
storage,
105-
v3,
106103
}
107104
}
108105
}
@@ -144,29 +141,12 @@ impl CKBProtocolHandler for RelayProtocol {
144141
}
145142
};
146143

147-
let ckb2023 = self
148-
.consensus
149-
.hardfork_switch
150-
.ckb2023
151-
.is_vm_version_2_and_syscalls_3_enabled(epoch);
152-
153144
debug!(
154-
"RelayProtocol V{}({}).connected peer={}, epoch={}",
155-
if self.v3 { '3' } else { '2' },
156-
version,
145+
"RelayProtocol.connected peer={}, version={}, epoch={}",
157146
peer,
147+
version,
158148
epoch
159149
);
160-
161-
if self.v3 && !ckb2023 {
162-
debug!("peer={} is not ckb2023 enabled, ignore", peer);
163-
return;
164-
}
165-
166-
if !self.v3 && ckb2023 {
167-
debug!("peer={} is ckb2023 enabled, ignore", peer);
168-
return;
169-
}
170150
#[cfg(target_arch = "wasm32")]
171151
let flag = self
172152
.pending_txs

wasm/light-client-wasm/src/lib.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,11 @@ pub async fn light_client(
188188
));
189189

190190
let sync_protocol = SyncProtocol::new(storage.clone(), Arc::clone(&peers));
191-
let relay_protocol_v2 = RelayProtocol::new(
191+
let relay_protocol = RelayProtocol::new(
192192
pending_txs.clone(),
193193
Arc::clone(&peers),
194194
consensus.clone(),
195195
storage.clone(),
196-
false,
197-
);
198-
let relay_protocol_v3 = RelayProtocol::new(
199-
pending_txs.clone(),
200-
Arc::clone(&peers),
201-
consensus.clone(),
202-
storage.clone(),
203-
true,
204196
);
205197
let light_client: Box<dyn CKBProtocolHandler> = Box::new(LightClientProtocol::new(
206198
storage.clone(),
@@ -216,14 +208,9 @@ pub async fn light_client(
216208
Box::new(sync_protocol),
217209
Arc::clone(&network_state),
218210
),
219-
CKBProtocol::new_with_support_protocol(
220-
SupportProtocols::RelayV2,
221-
Box::new(relay_protocol_v2),
222-
Arc::clone(&network_state),
223-
),
224211
CKBProtocol::new_with_support_protocol(
225212
SupportProtocols::RelayV3,
226-
Box::new(relay_protocol_v3),
213+
Box::new(relay_protocol),
227214
Arc::clone(&network_state),
228215
),
229216
CKBProtocol::new_with_support_protocol(

0 commit comments

Comments
 (0)