add BLOCK_HIST capabilities on startup if config archive_mode=true (#3563)

This commit is contained in:
Antioch Peverell 2021-02-23 11:40:48 +00:00 committed by GitHub
parent 9c44a4d08f
commit 08523b2b39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -391,6 +391,8 @@ bitflags! {
const TX_KERNEL_HASH = 0b0000_1000; const TX_KERNEL_HASH = 0b0000_1000;
/// Can provide PIBD segments during initial byte download (fast sync). /// Can provide PIBD segments during initial byte download (fast sync).
const PIBD_HIST = 0b0001_0000; const PIBD_HIST = 0b0001_0000;
/// Can provide historical blocks for archival sync.
const BLOCK_HIST = 0b0010_0000;
} }
} }

View file

@ -214,9 +214,13 @@ impl Server {
init_net_hooks(&config), init_net_hooks(&config),
)); ));
// Use our default capabilities here. // Initialize our capabilities.
// We will advertize these to our peers during hand/shake. // Currently either "default" or with optional "archive_mode" (block history) support enabled.
let capabilities = Capabilities::default(); let capabilities = if let Some(true) = config.archive_mode {
Capabilities::default() | Capabilities::BLOCK_HIST
} else {
Capabilities::default()
};
debug!("Capabilities: {:?}", capabilities); debug!("Capabilities: {:?}", capabilities);
let p2p_server = Arc::new(p2p::Server::new( let p2p_server = Arc::new(p2p::Server::new(