-
Notifications
You must be signed in to change notification settings - Fork 124
feat(l1): admin_addPeer endpoint #5004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dd83c34
3b8956c
fce102e
cc12b0a
0f3d680
9c74188
690ac54
7d3c01c
1ff99ff
ee01072
1d9bd33
75ccca1
743af2f
0025aef
762aba7
e71ab5d
c140755
3effd10
08724e7
d04cbcf
645e52f
c8b241a
c77b491
b5c5541
7b12203
dadc3fc
36b376b
0cfbc2c
e5bb9bc
b518b64
74b180f
cc33e10
e4aa61d
5d891c5
2a1b13b
dc2c063
35bc578
7473025
12d916d
3634bd3
ff21cc9
652dd94
5b9fceb
c7911f2
4c0c021
3093265
e6840cf
acf0e98
be31342
92e7570
7c9f024
a1b504f
4351c7e
a6d26b0
591b3ce
036b751
5e660a8
f814ee0
c7e29bd
12baa88
8add4d8
3459565
7206f7f
d95b72e
a79fb9a
e51ca4f
b3d2249
ce6526a
7600030
88cfbee
16c18f7
e3a4784
d96c071
96fc4ef
d429580
33e87c9
59d3f43
26a21b9
e541fe0
3b9b438
9ee1a18
45a65cf
84d1c7f
d17f68a
301d196
84b5db1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ use crate::{ | |
| metrics::METRICS, | ||
| rlpx::{ | ||
| connection::server::{PeerConnBroadcastSender, PeerConnection}, | ||
| initiator::RLPxInitiator, | ||
| message::Message, | ||
| p2p::SUPPORTED_SNAP_CAPABILITIES, | ||
| }, | ||
|
|
@@ -94,6 +93,36 @@ impl P2PContext { | |
| tx_broadcaster, | ||
| }) | ||
| } | ||
|
|
||
| #[cfg(any(test, feature = "test-utils"))] | ||
| /// Creates a dummy P2PContext for tests | ||
| /// This should only be used in tests as it won't be able to connect to the p2p network | ||
| pub async fn dummy(peer_table: PeerTable) -> P2PContext { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely happy with these
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at least it should be behind the test flag |
||
| use ethrex_storage::EngineType; | ||
|
|
||
| let storage = Store::new("./temp", EngineType::InMemory).expect("Failed to create Store"); | ||
| let blockchain: Arc<Blockchain> = Arc::new(Blockchain::default_with_store(storage.clone())); | ||
| let local_node = Node::from_enode_url( | ||
| "enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303", | ||
| ).expect("Bad enode url"); | ||
| let (channel_broadcast_send_end, _) = | ||
| tokio::sync::broadcast::channel::<(tokio::task::Id, Arc<Message>)>(100000); | ||
| P2PContext { | ||
| tracker: TaskTracker::default(), | ||
| signer: SecretKey::from_byte_array(&[0xcd; 32]).expect("32 bytes, within curve order"), | ||
| table: peer_table.clone(), | ||
| storage, | ||
| blockchain: blockchain.clone(), | ||
| broadcast: channel_broadcast_send_end, | ||
| local_node: local_node.clone(), | ||
| client_version: "".to_string(), | ||
| #[cfg(feature = "l2")] | ||
| based_context: None, | ||
| tx_broadcaster: TxBroadcaster::spawn(peer_table.clone(), blockchain, 1000) | ||
| .await | ||
| .expect("Failed to spawn tx broadcaster"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
|
|
@@ -123,8 +152,6 @@ pub async fn start_network(context: P2PContext, bootnodes: Vec<Node>) -> Result< | |
| error!("Failed to start discovery server: {e}"); | ||
| })?; | ||
|
|
||
| RLPxInitiator::spawn(context.clone()).await; | ||
|
|
||
| context.tracker.spawn(serve_p2p_requests(context.clone())); | ||
|
|
||
| Ok(()) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.