mirror of
https://github.com/markqvist/LXMF
synced 2026-11-27 13:52:19 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
575fbc9ffe | ||
|
|
c21da895b6 | ||
|
|
b172c7fcd4 | ||
|
|
61331b58d7 | ||
|
|
9ff76c0473 | ||
|
|
c9272c9218 | ||
|
|
36f0c17c8b | ||
|
|
aa406d1552 | ||
|
|
0cb771439f | ||
|
|
672d754238 | ||
|
|
0178fb0d4f | ||
|
|
19d8909b10 | ||
|
|
19f0fa7724 | ||
|
|
eefb1c8349 | ||
|
|
0e0d01a0b2 | ||
|
|
ac2c9c3a9b | ||
|
|
05f144ae50 | ||
|
|
a461fd415a |
No files matched your search
+17
-17
@@ -2,8 +2,7 @@ import time
|
|||||||
import RNS
|
import RNS
|
||||||
import RNS.vendor.umsgpack as msgpack
|
import RNS.vendor.umsgpack as msgpack
|
||||||
|
|
||||||
from .LXMF import APP_NAME, stamp_cost_from_app_data
|
from .LXMF import APP_NAME, stamp_cost_from_app_data, pn_announce_data_is_valid
|
||||||
|
|
||||||
from .LXMessage import LXMessage
|
from .LXMessage import LXMessage
|
||||||
|
|
||||||
class LXMFDeliveryAnnounceHandler:
|
class LXMFDeliveryAnnounceHandler:
|
||||||
@@ -15,7 +14,7 @@ class LXMFDeliveryAnnounceHandler:
|
|||||||
def received_announce(self, destination_hash, announced_identity, app_data):
|
def received_announce(self, destination_hash, announced_identity, app_data):
|
||||||
for lxmessage in self.lxmrouter.pending_outbound:
|
for lxmessage in self.lxmrouter.pending_outbound:
|
||||||
if destination_hash == lxmessage.destination_hash:
|
if destination_hash == lxmessage.destination_hash:
|
||||||
if lxmessage.method == LXMessage.DIRECT:
|
if lxmessage.method == LXMessage.DIRECT or lxmessage.method == LXMessage.OPPORTUNISTIC:
|
||||||
lxmessage.next_delivery_attempt = time.time()
|
lxmessage.next_delivery_attempt = time.time()
|
||||||
|
|
||||||
while self.lxmrouter.processing_outbound:
|
while self.lxmrouter.processing_outbound:
|
||||||
@@ -40,23 +39,24 @@ class LXMFPropagationAnnounceHandler:
|
|||||||
def received_announce(self, destination_hash, announced_identity, app_data):
|
def received_announce(self, destination_hash, announced_identity, app_data):
|
||||||
try:
|
try:
|
||||||
if type(app_data) == bytes:
|
if type(app_data) == bytes:
|
||||||
data = msgpack.unpackb(app_data)
|
|
||||||
|
|
||||||
if self.lxmrouter.propagation_node and self.lxmrouter.autopeer:
|
if self.lxmrouter.propagation_node and self.lxmrouter.autopeer:
|
||||||
node_timebase = data[1]
|
data = msgpack.unpackb(app_data)
|
||||||
propagation_transfer_limit = None
|
|
||||||
if len(data) >= 3:
|
|
||||||
try:
|
|
||||||
propagation_transfer_limit = float(data[2])
|
|
||||||
except:
|
|
||||||
propagation_transfer_limit = None
|
|
||||||
|
|
||||||
if data[0] == True:
|
if pn_announce_data_is_valid(data):
|
||||||
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
|
node_timebase = data[1]
|
||||||
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit)
|
propagation_transfer_limit = None
|
||||||
|
if len(data) >= 3:
|
||||||
|
try:
|
||||||
|
propagation_transfer_limit = float(data[2])
|
||||||
|
except:
|
||||||
|
propagation_transfer_limit = None
|
||||||
|
|
||||||
elif data[0] == False:
|
if data[0] == True:
|
||||||
self.lxmrouter.unpeer(destination_hash, node_timebase)
|
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
|
||||||
|
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit)
|
||||||
|
|
||||||
|
elif data[0] == False:
|
||||||
|
self.lxmrouter.unpeer(destination_hash, node_timebase)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
|
RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
|
||||||
|
|||||||
+25
-2
@@ -18,6 +18,7 @@ FIELD_RESULTS = 0x0A
|
|||||||
FIELD_GROUP = 0x0B
|
FIELD_GROUP = 0x0B
|
||||||
FIELD_TICKET = 0x0C
|
FIELD_TICKET = 0x0C
|
||||||
FIELD_EVENT = 0x0D
|
FIELD_EVENT = 0x0D
|
||||||
|
FIELD_RNR_REFS = 0x0E
|
||||||
|
|
||||||
# For usecases such as including custom data structures,
|
# For usecases such as including custom data structures,
|
||||||
# embedding or encapsulating other data types or protocols
|
# embedding or encapsulating other data types or protocols
|
||||||
@@ -82,6 +83,7 @@ AM_CUSTOM = 0xFF
|
|||||||
# handle and operate on LXMF data in client programs #
|
# handle and operate on LXMF data in client programs #
|
||||||
##########################################################
|
##########################################################
|
||||||
|
|
||||||
|
import RNS
|
||||||
import RNS.vendor.umsgpack as msgpack
|
import RNS.vendor.umsgpack as msgpack
|
||||||
def display_name_from_app_data(app_data=None):
|
def display_name_from_app_data(app_data=None):
|
||||||
if app_data == None:
|
if app_data == None:
|
||||||
@@ -103,8 +105,8 @@ def display_name_from_app_data(app_data=None):
|
|||||||
try:
|
try:
|
||||||
decoded = dn.decode("utf-8")
|
decoded = dn.decode("utf-8")
|
||||||
return decoded
|
return decoded
|
||||||
except:
|
except Exception as e:
|
||||||
RNS.log("Could not decode display name in included announce data. The contained exception was: {e}", RNS.LOG_ERROR)
|
RNS.log(f"Could not decode display name in included announce data. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Original announce format
|
# Original announce format
|
||||||
@@ -127,3 +129,24 @@ def stamp_cost_from_app_data(app_data=None):
|
|||||||
# Original announce format
|
# Original announce format
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def pn_announce_data_is_valid(data):
|
||||||
|
try:
|
||||||
|
if type(data) == bytes:
|
||||||
|
data = msgpack.unpackb(data)
|
||||||
|
|
||||||
|
if len(data) < 3:
|
||||||
|
raise ValueError("Invalid announce data: Insufficient peer data")
|
||||||
|
else:
|
||||||
|
if data[0] != True and data[0] != False:
|
||||||
|
raise ValueError("Invalid announce data: Indeterminate propagation node status")
|
||||||
|
try:
|
||||||
|
int(data[1])
|
||||||
|
except:
|
||||||
|
raise ValueError("Invalid announce data: Could not decode peer timebase")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log(f"Could not validate propagation node announce data: {e}", RNS.LOG_DEBUG)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
+7
-3
@@ -108,7 +108,10 @@ class LXMPeer:
|
|||||||
self.router = router
|
self.router = router
|
||||||
self.destination_hash = destination_hash
|
self.destination_hash = destination_hash
|
||||||
self.identity = RNS.Identity.recall(destination_hash)
|
self.identity = RNS.Identity.recall(destination_hash)
|
||||||
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
|
if self.identity != None:
|
||||||
|
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
|
||||||
|
else:
|
||||||
|
RNS.log(f"Could not recall identity for LXMF propagation peer {RNS.prettyhexrep(self.destination_hash)}, will retry identity resolution on next sync", RNS.LOG_WARNING)
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
RNS.log("Initiating LXMF Propagation Node sync with peer "+RNS.prettyhexrep(self.destination_hash), RNS.LOG_DEBUG)
|
RNS.log("Initiating LXMF Propagation Node sync with peer "+RNS.prettyhexrep(self.destination_hash), RNS.LOG_DEBUG)
|
||||||
@@ -126,9 +129,10 @@ class LXMPeer:
|
|||||||
else:
|
else:
|
||||||
if self.identity == None:
|
if self.identity == None:
|
||||||
self.identity = RNS.Identity.recall(destination_hash)
|
self.identity = RNS.Identity.recall(destination_hash)
|
||||||
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
|
if self.identity != None:
|
||||||
|
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
|
||||||
|
|
||||||
if self.identity != None:
|
if self.destination != None:
|
||||||
if len(self.unhandled_messages) > 0:
|
if len(self.unhandled_messages) > 0:
|
||||||
if self.state == LXMPeer.IDLE:
|
if self.state == LXMPeer.IDLE:
|
||||||
RNS.log("Establishing link for sync to peer "+RNS.prettyhexrep(self.destination_hash)+"...", RNS.LOG_DEBUG)
|
RNS.log("Establishing link for sync to peer "+RNS.prettyhexrep(self.destination_hash)+"...", RNS.LOG_DEBUG)
|
||||||
|
|||||||
+36
-24
@@ -284,11 +284,12 @@ class LXMRouter:
|
|||||||
if len(destination_hash) != RNS.Identity.TRUNCATED_HASHLENGTH//8 or type(destination_hash) != bytes:
|
if len(destination_hash) != RNS.Identity.TRUNCATED_HASHLENGTH//8 or type(destination_hash) != bytes:
|
||||||
raise ValueError("Invalid destination hash for outbound propagation node")
|
raise ValueError("Invalid destination hash for outbound propagation node")
|
||||||
else:
|
else:
|
||||||
self.outbound_propagation_node = destination_hash
|
if self.outbound_propagation_node != destination_hash:
|
||||||
if self.outbound_propagation_link != None:
|
self.outbound_propagation_node = destination_hash
|
||||||
if self.outbound_propagation_link.destination.hash != destination_hash:
|
if self.outbound_propagation_link != None:
|
||||||
self.outbound_propagation_link.teardown()
|
if self.outbound_propagation_link.destination.hash != destination_hash:
|
||||||
self.outbound_propagation_link = None
|
self.outbound_propagation_link.teardown()
|
||||||
|
self.outbound_propagation_link = None
|
||||||
|
|
||||||
def get_outbound_propagation_node(self):
|
def get_outbound_propagation_node(self):
|
||||||
return self.outbound_propagation_node
|
return self.outbound_propagation_node
|
||||||
@@ -350,6 +351,7 @@ class LXMRouter:
|
|||||||
if self.outbound_propagation_node != None:
|
if self.outbound_propagation_node != None:
|
||||||
if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.ACTIVE:
|
if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.ACTIVE:
|
||||||
self.propagation_transfer_state = LXMRouter.PR_LINK_ESTABLISHED
|
self.propagation_transfer_state = LXMRouter.PR_LINK_ESTABLISHED
|
||||||
|
RNS.log("Requesting message list from propagation node", RNS.LOG_DEBUG)
|
||||||
self.outbound_propagation_link.identify(identity)
|
self.outbound_propagation_link.identify(identity)
|
||||||
self.outbound_propagation_link.request(
|
self.outbound_propagation_link.request(
|
||||||
LXMPeer.MESSAGE_GET_PATH,
|
LXMPeer.MESSAGE_GET_PATH,
|
||||||
@@ -642,7 +644,7 @@ class LXMRouter:
|
|||||||
removed_entries = []
|
removed_entries = []
|
||||||
for transient_id in self.locally_delivered_transient_ids:
|
for transient_id in self.locally_delivered_transient_ids:
|
||||||
timestamp = self.locally_delivered_transient_ids[transient_id]
|
timestamp = self.locally_delivered_transient_ids[transient_id]
|
||||||
if now > timestamp+LXMRouter.MESSAGE_EXPIRY*1.25:
|
if now > timestamp+LXMRouter.MESSAGE_EXPIRY*6.0:
|
||||||
removed_entries.append(transient_id)
|
removed_entries.append(transient_id)
|
||||||
|
|
||||||
for transient_id in removed_entries:
|
for transient_id in removed_entries:
|
||||||
@@ -652,7 +654,7 @@ class LXMRouter:
|
|||||||
removed_entries = []
|
removed_entries = []
|
||||||
for transient_id in self.locally_processed_transient_ids:
|
for transient_id in self.locally_processed_transient_ids:
|
||||||
timestamp = self.locally_processed_transient_ids[transient_id]
|
timestamp = self.locally_processed_transient_ids[transient_id]
|
||||||
if now > timestamp+LXMRouter.MESSAGE_EXPIRY*1.25:
|
if now > timestamp+LXMRouter.MESSAGE_EXPIRY*6.0:
|
||||||
removed_entries.append(transient_id)
|
removed_entries.append(transient_id)
|
||||||
|
|
||||||
for transient_id in removed_entries:
|
for transient_id in removed_entries:
|
||||||
@@ -853,9 +855,8 @@ class LXMRouter:
|
|||||||
if not os.path.isdir(self.storagepath):
|
if not os.path.isdir(self.storagepath):
|
||||||
os.makedirs(self.storagepath)
|
os.makedirs(self.storagepath)
|
||||||
|
|
||||||
locally_delivered_file = open(self.storagepath+"/local_deliveries", "wb")
|
with open(self.storagepath+"/local_deliveries", "wb") as locally_delivered_file:
|
||||||
locally_delivered_file.write(msgpack.packb(self.locally_delivered_transient_ids))
|
locally_delivered_file.write(msgpack.packb(self.locally_delivered_transient_ids))
|
||||||
locally_delivered_file.close()
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not save locally delivered message ID cache to storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Could not save locally delivered message ID cache to storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
@@ -865,9 +866,8 @@ class LXMRouter:
|
|||||||
if not os.path.isdir(self.storagepath):
|
if not os.path.isdir(self.storagepath):
|
||||||
os.makedirs(self.storagepath)
|
os.makedirs(self.storagepath)
|
||||||
|
|
||||||
locally_processed_file = open(self.storagepath+"/locally_processed", "wb")
|
with open(self.storagepath+"/locally_processed", "wb") as locally_processed_file:
|
||||||
locally_processed_file.write(msgpack.packb(self.locally_processed_transient_ids))
|
locally_processed_file.write(msgpack.packb(self.locally_processed_transient_ids))
|
||||||
locally_processed_file.close()
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not save locally processed transient ID cache to storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Could not save locally processed transient ID cache to storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
@@ -922,7 +922,7 @@ class LXMRouter:
|
|||||||
expired_inbound.append(inbound_ticket)
|
expired_inbound.append(inbound_ticket)
|
||||||
|
|
||||||
for inbound_ticket in expired_inbound:
|
for inbound_ticket in expired_inbound:
|
||||||
self.available_tickets["inbound"][destination_hash].pop(destination_hash)
|
self.available_tickets["inbound"][destination_hash].pop(inbound_ticket)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log(f"Error while cleaning available tickets. The contained exception was: {e}", RNS.LOG_ERROR)
|
RNS.log(f"Error while cleaning available tickets. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||||
@@ -1123,24 +1123,32 @@ class LXMRouter:
|
|||||||
wants = []
|
wants = []
|
||||||
if len(request_receipt.response) > 0:
|
if len(request_receipt.response) > 0:
|
||||||
for transient_id in request_receipt.response:
|
for transient_id in request_receipt.response:
|
||||||
if not self.retain_synced_on_node and self.has_message(transient_id):
|
if self.has_message(transient_id):
|
||||||
haves.append(transient_id)
|
if not self.retain_synced_on_node:
|
||||||
|
haves.append(transient_id)
|
||||||
else:
|
else:
|
||||||
if self.propagation_transfer_max_messages == LXMRouter.PR_ALL_MESSAGES or len(wants) < self.propagation_transfer_max_messages:
|
if self.propagation_transfer_max_messages == LXMRouter.PR_ALL_MESSAGES or len(wants) < self.propagation_transfer_max_messages:
|
||||||
wants.append(transient_id)
|
wants.append(transient_id)
|
||||||
|
|
||||||
|
ms = "" if len(wants) == 1 else "s"
|
||||||
|
RNS.log(f"Requesting {len(wants)} message{ms} from propagation node", RNS.LOG_DEBUG)
|
||||||
request_receipt.link.request(
|
request_receipt.link.request(
|
||||||
LXMPeer.MESSAGE_GET_PATH,
|
LXMPeer.MESSAGE_GET_PATH,
|
||||||
[wants, haves, self.delivery_per_transfer_limit],
|
[wants, haves, self.delivery_per_transfer_limit],
|
||||||
response_callback=self.message_get_response,
|
response_callback=self.message_get_response,
|
||||||
failed_callback=self.message_get_failed,
|
failed_callback=self.message_get_failed,
|
||||||
progress_callback=self.message_get_progress
|
progress_callback=self.message_get_progress)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.propagation_transfer_state = LXMRouter.PR_COMPLETE
|
self.propagation_transfer_state = LXMRouter.PR_COMPLETE
|
||||||
self.propagation_transfer_progress = 1.0
|
self.propagation_transfer_progress = 1.0
|
||||||
self.propagation_transfer_last_result = 0
|
self.propagation_transfer_last_result = 0
|
||||||
|
|
||||||
|
else:
|
||||||
|
RNS.log("Invalid message list data received from propagation node", RNS.LOG_DEBUG)
|
||||||
|
if self.outbound_propagation_link != None:
|
||||||
|
self.outbound_propagation_link.teardown()
|
||||||
|
|
||||||
def message_get_response(self, request_receipt):
|
def message_get_response(self, request_receipt):
|
||||||
if request_receipt.response == LXMPeer.ERROR_NO_IDENTITY:
|
if request_receipt.response == LXMPeer.ERROR_NO_IDENTITY:
|
||||||
RNS.log("Propagation node indicated missing identification on get request, tearing down link.", RNS.LOG_DEBUG)
|
RNS.log("Propagation node indicated missing identification on get request, tearing down link.", RNS.LOG_DEBUG)
|
||||||
@@ -1804,13 +1812,17 @@ class LXMRouter:
|
|||||||
lxmessage.delivery_attempts += 1
|
lxmessage.delivery_attempts += 1
|
||||||
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
||||||
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
||||||
lxmessage.progress = 0.00
|
lxmessage.progress = 0.01
|
||||||
elif lxmessage.delivery_attempts == LXMRouter.MAX_PATHLESS_TRIES+3 and RNS.Transport.has_path(lxmessage.get_destination().hash):
|
elif lxmessage.delivery_attempts == LXMRouter.MAX_PATHLESS_TRIES+1 and RNS.Transport.has_path(lxmessage.get_destination().hash):
|
||||||
RNS.log(f"Opportunistic delivery for {lxmessage} still unsuccessful after {lxmessage.delivery_attempts} attempts, trying to update path to {RNS.prettyhexrep(lxmessage.get_destination().hash)}", RNS.LOG_DEBUG)
|
RNS.log(f"Opportunistic delivery for {lxmessage} still unsuccessful after {lxmessage.delivery_attempts} attempts, trying to rediscover path to {RNS.prettyhexrep(lxmessage.get_destination().hash)}", RNS.LOG_DEBUG)
|
||||||
lxmessage.delivery_attempts += 1
|
lxmessage.delivery_attempts += 1
|
||||||
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
RNS.Reticulum.get_instance().drop_path(lxmessage.get_destination().hash)
|
||||||
|
def rediscover_job():
|
||||||
|
time.sleep(0.5)
|
||||||
|
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
||||||
|
threading.Thread(target=rediscover_job, daemon=True).start()
|
||||||
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
||||||
lxmessage.progress = 0.00
|
lxmessage.progress = 0.01
|
||||||
else:
|
else:
|
||||||
if not hasattr(lxmessage, "next_delivery_attempt") or time.time() > lxmessage.next_delivery_attempt:
|
if not hasattr(lxmessage, "next_delivery_attempt") or time.time() > lxmessage.next_delivery_attempt:
|
||||||
lxmessage.delivery_attempts += 1
|
lxmessage.delivery_attempts += 1
|
||||||
@@ -1896,7 +1908,7 @@ class LXMRouter:
|
|||||||
RNS.log("No path known for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+". Requesting path...", RNS.LOG_DEBUG)
|
RNS.log("No path known for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+". Requesting path...", RNS.LOG_DEBUG)
|
||||||
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
RNS.Transport.request_path(lxmessage.get_destination().hash)
|
||||||
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
|
||||||
lxmessage.progress = 0.00
|
lxmessage.progress = 0.01
|
||||||
else:
|
else:
|
||||||
RNS.log("Max delivery attempts reached for direct "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
|
RNS.log("Max delivery attempts reached for direct "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
|
||||||
self.fail_message(lxmessage)
|
self.fail_message(lxmessage)
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ def stamp_value(workblock, stamp):
|
|||||||
value = 0
|
value = 0
|
||||||
bits = 256
|
bits = 256
|
||||||
material = RNS.Identity.full_hash(workblock+stamp)
|
material = RNS.Identity.full_hash(workblock+stamp)
|
||||||
i = int.from_bytes(material)
|
i = int.from_bytes(material, byteorder="big")
|
||||||
while ((i & (1 << (bits - 1))) == 0):
|
while ((i & (1 << (bits - 1))) == 0):
|
||||||
i = (i << 1)
|
i = (i << 1)
|
||||||
value += 1
|
value += 1
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__ = "0.5.2"
|
__version__ = "0.5.8"
|
||||||
Reference in new issue
Block a user