parent
55cedfea9c
commit
abba36ac6c
@ -34,6 +34,7 @@ class SessionBase(JSONSession):
|
|||||||
self.env = controller.env
|
self.env = controller.env
|
||||||
self.daemon = self.bp.daemon
|
self.daemon = self.bp.daemon
|
||||||
self.client = 'unknown'
|
self.client = 'unknown'
|
||||||
|
self.client_version = (1)
|
||||||
self.protocol_version = '1.0'
|
self.protocol_version = '1.0'
|
||||||
self.anon_logs = self.env.anon_logs
|
self.anon_logs = self.env.anon_logs
|
||||||
self.last_delay = 0
|
self.last_delay = 0
|
||||||
@ -262,14 +263,15 @@ class ElectrumX(SessionBase):
|
|||||||
|
|
||||||
index: the chunk index'''
|
index: the chunk index'''
|
||||||
index = self.controller.non_negative_integer(index)
|
index = self.controller.non_negative_integer(index)
|
||||||
self.chunk_indices.append(index)
|
if self.client_version < (2, 8, 3):
|
||||||
self.chunk_indices = self.chunk_indices[-5:]
|
self.chunk_indices.append(index)
|
||||||
# -2 allows backing up a single chunk but no more.
|
self.chunk_indices = self.chunk_indices[-5:]
|
||||||
if index <= max(self.chunk_indices[:-2], default=-1):
|
# -2 allows backing up a single chunk but no more.
|
||||||
msg = ('chunk indices not advancing (wrong network?): {}'
|
if index <= max(self.chunk_indices[:-2], default=-1):
|
||||||
.format(self.chunk_indices))
|
msg = ('chunk indices not advancing (wrong network?): {}'
|
||||||
# INVALID_REQUEST triggers a disconnect
|
.format(self.chunk_indices))
|
||||||
raise RPCError(msg, JSONRPC.INVALID_REQUEST)
|
# use INVALID_REQUEST to trigger a disconnect
|
||||||
|
raise RPCError(msg, JSONRPC.INVALID_REQUEST)
|
||||||
return self.controller.get_chunk(index)
|
return self.controller.get_chunk(index)
|
||||||
|
|
||||||
def is_tor(self):
|
def is_tor(self):
|
||||||
@ -323,6 +325,11 @@ class ElectrumX(SessionBase):
|
|||||||
'''
|
'''
|
||||||
if client_name:
|
if client_name:
|
||||||
self.client = str(client_name)[:17]
|
self.client = str(client_name)[:17]
|
||||||
|
try:
|
||||||
|
self.client_version = tuple(int(part) for part
|
||||||
|
in self.client.split('.'))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
if protocol_version is not None:
|
if protocol_version is not None:
|
||||||
self.protocol_version = protocol_version
|
self.protocol_version = protocol_version
|
||||||
return version.VERSION
|
return version.VERSION
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user