mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Include latest_block_height in lookup response (#627)
This commit is contained in:
parent
5572ee07d0
commit
b26c3ea9df
3 changed files with 15 additions and 4 deletions
|
|
@ -61,11 +61,14 @@ message GetSqueakReply {
|
|||
}
|
||||
|
||||
message LookupSqueaksReply {
|
||||
/// Hash of the squeak to get.
|
||||
repeated bytes hashes = 1;
|
||||
/// Height of the latest block.
|
||||
int32 latest_block_height = 1;
|
||||
|
||||
/// Hash of the squeak to get.
|
||||
repeated string allowed_addresses = 2;
|
||||
repeated bytes hashes = 2;
|
||||
|
||||
/// Hash of the squeak to get.
|
||||
repeated string allowed_addresses = 3;
|
||||
}
|
||||
|
||||
message GetOfferReply {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ class SqueakServerHandler(object):
|
|||
"Got number of allowed addresses from db: {}".format(
|
||||
len(allowed_addresses))
|
||||
)
|
||||
latest_block_height = self.squeak_controller.get_best_block_height()
|
||||
return squeak_server_pb2.LookupSqueaksReply(
|
||||
latest_block_height=latest_block_height,
|
||||
hashes=hashes,
|
||||
allowed_addresses=allowed_addresses,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class PeerSyncTask:
|
|||
hashes_to_download = set(remote_hashes) - set(local_hashes)
|
||||
|
||||
# Download squeaks for the hashes
|
||||
# TODO: catch exception downloading individual squeak
|
||||
# TODO: catch exception downloading individual squeak.
|
||||
# TODO: check if hash belongs to correct range after downloading.
|
||||
for hash in hashes_to_download:
|
||||
if self.peer_connection.stopped():
|
||||
return
|
||||
|
|
@ -70,6 +71,11 @@ class PeerSyncTask:
|
|||
addresses, min_block, max_block)
|
||||
remote_hashes = lookup_result.hashes
|
||||
allowed_addresses = lookup_result.allowed_addresses
|
||||
peer_latest_block = lookup_result.latest_block_height
|
||||
|
||||
max_block = min(max_block, peer_latest_block)
|
||||
if max_block < min_block:
|
||||
return
|
||||
|
||||
# Get local hashes
|
||||
local_hashes = self._get_local_unlocked_hashes(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue