Skip to content

Commit

Permalink
Merge branch 'main' into ui-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Apr 12, 2023
2 parents d88db7b + ddc06a4 commit 6097f5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
15 changes: 7 additions & 8 deletions packages/frontend/src/lib/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ export async function startLibp2p(options: {} = {}) {
}),],
connectionEncryption: [noise()],
streamMuxers: [yamux()],
// #TODO: To be set to the statically generated rust peer id
// peerDiscovery: [
// bootstrap({
// list: [
// '/ip4/127.0.0.1/udp/9090/webrtc-direct/certhash/uEiBy_U1UNQ0IDvot_PKlQM_QeU3yx-zCAVaMxxVm2JxWBg/p2p/12D3KooWPMwgZXKP6uXLoCy9ALSQeFiGJDTSggbYPHyN4dFTJpmC',
// ],
// }),
// ],
peerDiscovery: [
bootstrap({
list: [
'/ip4/18.195.246.16/udp/9090/webrtc-direct/certhash/uEiBy_U1UNQ0IDvot_PKlQM_QeU3yx-zCAVaMxxVm2JxWBg/p2p/12D3KooWGTDZj1zAjMCJ8XXx9Z88zAAd6vn3krQYLwZ67S4vMUxz',
],
}),
],
pubsub: gossipsub({
allowPublishToZeroPeers: true,
msgIdFn: msgIdFnStrictNoSign,
Expand Down
15 changes: 12 additions & 3 deletions rust-peer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use log::{debug, error, info, warn};
use std::{
borrow::Cow,
collections::hash_map::DefaultHasher,
fs::File,
hash::{Hash, Hasher},
io::{BufReader, Read},
time::{Duration, Instant},
};

Expand Down Expand Up @@ -184,7 +186,7 @@ async fn main() -> Result<()> {
}
}
SwarmEvent::Behaviour(BehaviourEvent::Kademlia(e)) => {
info!("Kademlia event: {:?}", e);
debug!("Kademlia event: {:?}", e);
}
event => {
debug!("Other type of event: {:?}", event);
Expand All @@ -193,7 +195,7 @@ async fn main() -> Result<()> {
futures::future::Either::Right(_) => {
tick = futures_timer::Delay::new(TICK_INTERVAL);

info!(
debug!(
"external addrs: {:?}",
swarm.external_addresses().collect::<Vec<&AddressRecord>>()
);
Expand Down Expand Up @@ -226,7 +228,14 @@ struct Behaviour {
}

fn create_swarm() -> Result<Swarm<Behaviour>> {
let local_key = identity::Keypair::generate_ed25519();
let f = File::open("/home/ec2-user/private_key")?;
let mut reader = BufReader::new(f);
let mut buffer = Vec::new();

reader.read_to_end(&mut buffer)?;

let local_key = identity::Keypair::ed25519_from_bytes(&mut buffer)?;

let local_peer_id = PeerId::from(local_key.public());
debug!("Local peer id: {local_peer_id}");

Expand Down

0 comments on commit 6097f5a

Please sign in to comment.