mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
InboundSession stub which accepts new connections
This commit is contained in:
@@ -5,7 +5,7 @@ use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::net::sessions::SeedSession;
|
||||
use crate::net::sessions::{SeedSession, InboundSession};
|
||||
use crate::net::{Channel, ChannelPtr, Hosts, HostsPtr, Connector, Settings, SettingsPtr};
|
||||
|
||||
pub type Pending<T> = Mutex<HashMap<SocketAddr, Arc<T>>>;
|
||||
@@ -41,10 +41,10 @@ impl P2p {
|
||||
|
||||
/// Synchronize the blockchain and then begin long running sessions,
|
||||
/// call after start() is invoked.
|
||||
pub fn run() {
|
||||
//let inbound = InboundSession::new(Arc::downgrade(&self));
|
||||
//let inbound_task = inbound.start(executor.clone());
|
||||
//inbound_task.await;
|
||||
pub async fn run(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
|
||||
let inbound = InboundSession::new(Arc::downgrade(&self));
|
||||
let inbound_task = inbound.start(executor.clone());
|
||||
inbound_task.await
|
||||
}
|
||||
|
||||
pub async fn store(self: Arc<Self>, channel: ChannelPtr) {
|
||||
|
||||
30
src/net/sessions/inbound_session.rs
Normal file
30
src/net/sessions/inbound_session.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use async_executor::Executor;
|
||||
use log::*;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
use crate::net::sessions::Session;
|
||||
use crate::net::{ChannelPtr, HostsPtr, Connector, P2p, SettingsPtr};
|
||||
use crate::net::protocols::{ProtocolPing, ProtocolSeed};
|
||||
|
||||
pub struct InboundSession {
|
||||
p2p: Weak<P2p>
|
||||
}
|
||||
|
||||
impl InboundSession {
|
||||
pub fn new(p2p: Weak<P2p>) -> Arc<Self> {
|
||||
Arc::new(Self { p2p })
|
||||
}
|
||||
|
||||
pub async fn start(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Session for InboundSession {
|
||||
fn p2p(&self) -> Arc<P2p> {
|
||||
self.p2p.upgrade().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
pub mod inbound_session;
|
||||
pub mod seed_session;
|
||||
pub mod session;
|
||||
|
||||
pub use inbound_session::InboundSession;
|
||||
pub use seed_session::SeedSession;
|
||||
pub use session::Session;
|
||||
|
||||
Reference in New Issue
Block a user