mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
darkfid: Run P2P on all sessions.
This commit is contained in:
@@ -21,11 +21,11 @@ use darkfi::{
|
||||
cli_desc,
|
||||
consensus2::{
|
||||
proto::{
|
||||
ProtocolParticipant, ProtocolProposal, ProtocolSync, ProtocolSyncForks, ProtocolTx,
|
||||
ProtocolParticipant, ProtocolProposal, ProtocolSync, ProtocolSyncConsensus, ProtocolTx,
|
||||
ProtocolVote,
|
||||
},
|
||||
state::ValidatorStatePtr,
|
||||
task::{block_sync_task, fork_sync_task, proposal_task},
|
||||
task::{block_sync_task, proposal_task},
|
||||
util::Timestamp,
|
||||
ValidatorState, MAINNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_HASH_BYTES,
|
||||
},
|
||||
@@ -469,8 +469,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
|
||||
let _state = state.clone();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
async move { ProtocolSync::init(channel, state, p2p, args.consensus).await.unwrap() }
|
||||
})
|
||||
@@ -478,8 +477,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
|
||||
let _state = state.clone();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
async move { ProtocolTx::init(channel, state, p2p).await.unwrap() }
|
||||
})
|
||||
@@ -507,8 +505,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
|
||||
let _state = state.clone();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
async move { ProtocolParticipant::init(channel, state, p2p).await.unwrap() }
|
||||
})
|
||||
@@ -516,8 +513,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
|
||||
let _state = state.clone();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
async move { ProtocolProposal::init(channel, state, p2p).await.unwrap() }
|
||||
})
|
||||
@@ -526,8 +522,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
let _state = state.clone();
|
||||
let _sync_p2p = sync_p2p.clone().unwrap();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
let __sync_p2p = _sync_p2p.clone();
|
||||
async move {
|
||||
@@ -540,10 +535,9 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
|
||||
let _state = state.clone();
|
||||
registry
|
||||
//.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
.register(!net::SESSION_SEED, move |channel, p2p| {
|
||||
.register(net::SESSION_ALL, move |channel, p2p| {
|
||||
let state = _state.clone();
|
||||
async move { ProtocolSyncForks::init(channel, state, p2p).await.unwrap() }
|
||||
async move { ProtocolSyncConsensus::init(channel, state, p2p).await.unwrap() }
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -591,14 +585,7 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
|
||||
.detach();
|
||||
|
||||
info!("Starting consensus protocol task");
|
||||
match fork_sync_task(consensus_p2p.clone().unwrap(), state.clone()).await {
|
||||
Ok(()) => {
|
||||
ex.spawn(proposal_task(consensus_p2p.unwrap(), state)).detach();
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to sync consensus forks. Not starting consensus: {}", e);
|
||||
}
|
||||
}
|
||||
ex.spawn(proposal_task(consensus_p2p.unwrap(), state)).detach();
|
||||
}
|
||||
|
||||
// Wait for SIGINT
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, net::SocketAddr};
|
||||
use std::{collections::HashMap, net::SocketAddr, str::FromStr};
|
||||
|
||||
use async_executor::Executor;
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -50,7 +50,7 @@ pub async fn proposal_task(p2p: net::P2pPtr, state: ValidatorStatePtr) {
|
||||
|
||||
loop {
|
||||
let seconds_until_next_epoch = state.read().await.next_epoch_start().as_secs();
|
||||
info!(target: "consensus", "Waiting for next epoch ({}) sec)...", seconds_until_next_epoch);
|
||||
info!(target: "consensus", "Waiting for next epoch ({:?} sec)...", seconds_until_next_epoch);
|
||||
sleep(seconds_until_next_epoch).await;
|
||||
|
||||
// Node refreshes participants records
|
||||
|
||||
Reference in New Issue
Block a user