fix reverse start block check
This commit is contained in:
parent
08587a1f56
commit
e57ab96731
@ -96,10 +96,8 @@ struct Max(usize);
|
|||||||
impl Constraint for StartsAtNumber {
|
impl Constraint for StartsAtNumber {
|
||||||
type Error = BasicError;
|
type Error = BasicError;
|
||||||
|
|
||||||
fn verify(&self, headers: &[Header], reverse: bool) -> Result<(), BasicError> {
|
fn verify(&self, headers: &[Header], _reverse: bool) -> Result<(), BasicError> {
|
||||||
let earliest = if reverse { headers.last() } else { headers.first() };
|
headers.first().map_or(Ok(()), |h| {
|
||||||
|
|
||||||
earliest.map_or(Ok(()), |h| {
|
|
||||||
if h.number() == self.0 {
|
if h.number() == self.0 {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@ -112,10 +110,8 @@ impl Constraint for StartsAtNumber {
|
|||||||
impl Constraint for StartsAtHash {
|
impl Constraint for StartsAtHash {
|
||||||
type Error = BasicError;
|
type Error = BasicError;
|
||||||
|
|
||||||
fn verify(&self, headers: &[Header], reverse: bool) -> Result<(), BasicError> {
|
fn verify(&self, headers: &[Header], _reverse: bool) -> Result<(), BasicError> {
|
||||||
let earliest = if reverse { headers.last() } else { headers.first() };
|
headers.first().map_or(Ok(()), |h| {
|
||||||
|
|
||||||
earliest.map_or(Ok(()), |h| {
|
|
||||||
if h.hash() == self.0 {
|
if h.hash() == self.0 {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +184,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn sequential_backward() {
|
fn sequential_backward() {
|
||||||
let request = HeadersRequest {
|
let request = HeadersRequest {
|
||||||
start: 10.into(),
|
start: 34.into(),
|
||||||
max: 30,
|
max: 30,
|
||||||
skip: 0,
|
skip: 0,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user