Skip to content

Commit

Permalink
Merge pull request #3 from mysteriumnetwork/fast_path
Browse files Browse the repository at this point in the history
fast path
  • Loading branch information
Snawoot authored Aug 26, 2022
2 parents 25dc0b7 + 189c47e commit bc54cfc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ func LastCommonBlock(ctx context.Context, left, right Client, offset uint64) (ui
highestCommonBlock -= offset
log.Printf("highestCommonBlock (safe value) = 0x%x (%d)", highestCommonBlock, highestCommonBlock)

// fast path
leftBlock, rightBlock, err := getBlocks(ctx, left, right, highestCommonBlock)
if err != nil {
return 0, 0, err
}
if leftBlock.Hash() == rightBlock.Hash() {
return highestCommonBlock, highestCommonBlock, nil
}

res, err := search(highestCommonBlock+1, func(blockNumber uint64) (bool, error) {

leftBlock, rightBlock, err := getBlocks(ctx, left, right, blockNumber)
Expand Down

0 comments on commit bc54cfc

Please sign in to comment.