Consistently use `network_setup` for the Inbound Setup
This commit is contained in:
parent
1c8362fe01
commit
134a5e78bd
|
@ -110,7 +110,7 @@ pub struct Inbound {
|
||||||
/// Provides network-dependent services, if they are available.
|
/// Provides network-dependent services, if they are available.
|
||||||
///
|
///
|
||||||
/// Some services are unavailable until Zebra has completed network setup.
|
/// Some services are unavailable until Zebra has completed network setup.
|
||||||
network: Setup,
|
network_setup: Setup,
|
||||||
|
|
||||||
/// A service that manages cached blockchain state.
|
/// A service that manages cached blockchain state.
|
||||||
state: State,
|
state: State,
|
||||||
|
@ -123,7 +123,7 @@ impl Inbound {
|
||||||
verifier: Verifier,
|
verifier: Verifier,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
network: Setup::AwaitingNetwork {
|
network_setup: Setup::AwaitingNetwork {
|
||||||
network_setup,
|
network_setup,
|
||||||
verifier,
|
verifier,
|
||||||
},
|
},
|
||||||
|
@ -132,9 +132,9 @@ impl Inbound {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_setup(&mut self) -> Setup {
|
fn take_setup(&mut self) -> Setup {
|
||||||
let mut network = Setup::FailedInit;
|
let mut network_setup = Setup::FailedInit;
|
||||||
std::mem::swap(&mut self.network, &mut network);
|
std::mem::swap(&mut self.network_setup, &mut network_setup);
|
||||||
network
|
network_setup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ impl Service<zn::Request> for Inbound {
|
||||||
// to load from being unready while waiting on setup.
|
// to load from being unready while waiting on setup.
|
||||||
let mut result = Ok(());
|
let mut result = Ok(());
|
||||||
|
|
||||||
self.network = match self.take_setup() {
|
self.network_setup = match self.take_setup() {
|
||||||
Setup::AwaitingNetwork {
|
Setup::AwaitingNetwork {
|
||||||
mut network_setup,
|
mut network_setup,
|
||||||
verifier,
|
verifier,
|
||||||
|
@ -219,7 +219,7 @@ impl Service<zn::Request> for Inbound {
|
||||||
fn call(&mut self, req: zn::Request) -> Self::Future {
|
fn call(&mut self, req: zn::Request) -> Self::Future {
|
||||||
match req {
|
match req {
|
||||||
zn::Request::Peers => {
|
zn::Request::Peers => {
|
||||||
if let Setup::Initialized { address_book, .. } = &self.network {
|
if let Setup::Initialized { address_book, .. } = &self.network_setup {
|
||||||
// We could truncate the list to try to not reveal our entire
|
// We could truncate the list to try to not reveal our entire
|
||||||
// peer set. But because we don't monitor repeated requests,
|
// peer set. But because we don't monitor repeated requests,
|
||||||
// this wouldn't actually achieve anything, because a crawler
|
// this wouldn't actually achieve anything, because a crawler
|
||||||
|
@ -296,7 +296,7 @@ impl Service<zn::Request> for Inbound {
|
||||||
async { Ok(zn::Response::Nil) }.boxed()
|
async { Ok(zn::Response::Nil) }.boxed()
|
||||||
}
|
}
|
||||||
zn::Request::AdvertiseBlock(hash) => {
|
zn::Request::AdvertiseBlock(hash) => {
|
||||||
if let Setup::Initialized { downloads, .. } = &mut self.network {
|
if let Setup::Initialized { downloads, .. } = &mut self.network_setup {
|
||||||
downloads.download_and_verify(hash);
|
downloads.download_and_verify(hash);
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
|
|
Loading…
Reference in New Issue