From 08523b2b39b1ba6b6a52e04f190bad847e1421df Mon Sep 17 00:00:00 2001 From: Antioch Peverell Date: Tue, 23 Feb 2021 11:40:48 +0000 Subject: [PATCH] add BLOCK_HIST capabilities on startup if config archive_mode=true (#3563) --- p2p/src/types.rs | 2 ++ servers/src/grin/server.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/p2p/src/types.rs b/p2p/src/types.rs index 35248ad00..2a89846bf 100644 --- a/p2p/src/types.rs +++ b/p2p/src/types.rs @@ -391,6 +391,8 @@ bitflags! { const TX_KERNEL_HASH = 0b0000_1000; /// Can provide PIBD segments during initial byte download (fast sync). const PIBD_HIST = 0b0001_0000; + /// Can provide historical blocks for archival sync. + const BLOCK_HIST = 0b0010_0000; } } diff --git a/servers/src/grin/server.rs b/servers/src/grin/server.rs index 5679756e9..929f675c8 100644 --- a/servers/src/grin/server.rs +++ b/servers/src/grin/server.rs @@ -214,9 +214,13 @@ impl Server { init_net_hooks(&config), )); - // Use our default capabilities here. - // We will advertize these to our peers during hand/shake. - let capabilities = Capabilities::default(); + // Initialize our capabilities. + // Currently either "default" or with optional "archive_mode" (block history) support enabled. + let capabilities = if let Some(true) = config.archive_mode { + Capabilities::default() | Capabilities::BLOCK_HIST + } else { + Capabilities::default() + }; debug!("Capabilities: {:?}", capabilities); let p2p_server = Arc::new(p2p::Server::new(