Skip to content

Commit 0428a37

Browse files
committed
tweak: apply review comments
Signed-off-by: ljedrz <ljedrz@users.noreply.github.com>
1 parent fba743b commit 0428a37

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

cli/src/commands/start.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ pub struct Start {
156156
pub bft: Option<SocketAddr>,
157157

158158
/// Set the IP address and port used for providing block synchronization.
159+
/// The default is 0.0.0.0:6130 if not specified.
159160
#[clap(long = "sync-listener")]
160161
pub sync_listener: Option<SocketAddr>,
161162

@@ -512,7 +513,7 @@ impl Start {
512513
}
513514

514515
if self.sync_listener.is_none() {
515-
let port = get_devnet_router_address_for_node(dev).port() + 2000; // 6130+
516+
let port = get_devnet_sync_address_for_node(dev).port();
516517
let address = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, port));
517518
debug!("Setting sync listener address to {address} due to dev={dev}");
518519
self.sync_listener = Some(address);

cli/src/helpers/dev.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
use snarkos_node::{bft::MEMORY_POOL_PORT, router::DEFAULT_NODE_PORT};
16+
use snarkos_node::{bft::MEMORY_POOL_PORT, network::DEFAULT_SYNC_PORT, router::DEFAULT_NODE_PORT};
1717

1818
use snarkvm::{console::network::Network, prelude::PrivateKey};
1919

@@ -58,3 +58,8 @@ pub fn get_devnet_gateway_address_for_validator(dev: u16) -> SocketAddr {
5858
pub fn get_devnet_router_address_for_node(dev: u16) -> SocketAddr {
5959
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, DEFAULT_NODE_PORT + dev))
6060
}
61+
62+
/// Returns the router address a particular devnet validator will list on.
63+
pub fn get_devnet_sync_address_for_node(dev: u16) -> SocketAddr {
64+
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, DEFAULT_SYNC_PORT + dev))
65+
}

node/network/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ pub mod built_info {
5858
include!(concat!(env!("OUT_DIR"), "/built.rs"));
5959
}
6060

61+
/// The default port used for the sync streams.
62+
pub const DEFAULT_SYNC_PORT: u16 = 6130;
63+
6164
/// Returns the list of bootstrap peers.
6265
#[allow(clippy::if_same_then_else)]
6366
pub fn bootstrap_peers<N: Network>(is_dev: bool) -> Vec<SocketAddr> {

node/sync/src/helpers/sync_channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ const MAX_CHANNEL_SIZE: usize = 8192;
2626

2727
#[derive(Clone, Debug)]
2828
pub struct SyncSender<N: Network> {
29-
pub tx_block_sync_insert_block_response: mpsc::Sender<(
29+
tx_block_sync_insert_block_response: mpsc::Sender<(
3030
SocketAddr,
3131
Vec<Block<N>>,
3232
Option<ConsensusVersion>,
3333
oneshot::Sender<Result<(), InsertBlockResponseError<N>>>,
3434
)>,
3535
pub tx_block_sync_remove_peer: mpsc::Sender<(SocketAddr, oneshot::Sender<()>)>,
36-
pub tx_block_sync_update_peer_locators: mpsc::Sender<(SocketAddr, BlockLocators<N>, oneshot::Sender<Result<()>>)>,
36+
tx_block_sync_update_peer_locators: mpsc::Sender<(SocketAddr, BlockLocators<N>, oneshot::Sender<Result<()>>)>,
3737
pub tx_certificate_request: mpsc::Sender<(SocketAddr, CertificateRequest<N>)>,
3838
pub tx_certificate_response: mpsc::Sender<(SocketAddr, CertificateResponse<N>)>,
3939
}

0 commit comments

Comments
 (0)