From e57ab967311d545623e2b59573f68e26a8948211 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 16 Dec 2016 23:21:59 +0100 Subject: [PATCH] fix reverse start block check --- sync/src/light_sync/response.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sync/src/light_sync/response.rs b/sync/src/light_sync/response.rs index 131f7e4e2..907db763e 100644 --- a/sync/src/light_sync/response.rs +++ b/sync/src/light_sync/response.rs @@ -96,10 +96,8 @@ struct Max(usize); impl Constraint for StartsAtNumber { type Error = BasicError; - fn verify(&self, headers: &[Header], reverse: bool) -> Result<(), BasicError> { - let earliest = if reverse { headers.last() } else { headers.first() }; - - earliest.map_or(Ok(()), |h| { + fn verify(&self, headers: &[Header], _reverse: bool) -> Result<(), BasicError> { + headers.first().map_or(Ok(()), |h| { if h.number() == self.0 { Ok(()) } else { @@ -112,10 +110,8 @@ impl Constraint for StartsAtNumber { impl Constraint for StartsAtHash { type Error = BasicError; - fn verify(&self, headers: &[Header], reverse: bool) -> Result<(), BasicError> { - let earliest = if reverse { headers.last() } else { headers.first() }; - - earliest.map_or(Ok(()), |h| { + fn verify(&self, headers: &[Header], _reverse: bool) -> Result<(), BasicError> { + headers.first().map_or(Ok(()), |h| { if h.hash() == self.0 { Ok(()) } else { @@ -188,7 +184,7 @@ mod tests { #[test] fn sequential_backward() { let request = HeadersRequest { - start: 10.into(), + start: 34.into(), max: 30, skip: 0, reverse: true,