Fix mixmate and sneakernet

master
Kevin Froman 2020-10-14 00:07:41 +00:00
parent 2291d5a5f2
commit e0f59784b1
4 changed files with 19 additions and 6 deletions

View File

@ -39,7 +39,10 @@ def block_mixer(upload_list: List[onionrtypes.BlockHash],
""" """
bl = onionrblockapi.Block(block_to_mix) bl = onionrblockapi.Block(block_to_mix)
try:
if time.time() - bl.claimedTime > onionrvalues.BLOCK_POOL_MAX_AGE: if time.time() - bl.claimedTime > onionrvalues.BLOCK_POOL_MAX_AGE:
raise ValueError raise ValueError
except TypeError:
pass
if block_to_mix: if block_to_mix:
upload_list.append(block_to_mix) upload_list.append(block_to_mix)

View File

@ -183,8 +183,9 @@ def insert_block(data: Union[str, bytes], header: str = 'txt',
# if peer is already known # if peer is already known
pass pass
else: else:
logger.warn(f"{asymPeer} is not a valid key to make a block to")
raise onionrexceptions.InvalidPubkey( raise onionrexceptions.InvalidPubkey(
asymPeer + ' is not a valid base32 encoded ed25519 key') 'tried to make block to invalid key is not a valid base32 encoded ed25519 key')
# compile metadata # compile metadata
metadata['meta'] = jsonMeta metadata['meta'] = jsonMeta

View File

@ -37,8 +37,11 @@ class _Importer(FileSystemEventHandler):
def on_created(event): def on_created(event):
if not event.src_path.endswith(BLOCK_EXPORT_FILE_EXT): if not event.src_path.endswith(BLOCK_EXPORT_FILE_EXT):
return return
try:
with open(event.src_path, 'rb') as block_file: with open(event.src_path, 'rb') as block_file:
block_data = block_file.read() block_data = block_file.read()
except FileNotFoundError:
return
os.remove(event.src_path) os.remove(event.src_path)
try: try:
import_block_from_data(block_data) import_block_from_data(block_data)

View File

@ -21,7 +21,7 @@ import deadsimplekv as simplekv
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
inbox_cache = {}
def load_inbox(): def load_inbox():
inbox_list = [] inbox_list = []
deleted = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat').get('deleted_mail') deleted = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/mailcache.dat').get('deleted_mail')
@ -29,8 +29,14 @@ def load_inbox():
deleted = [] deleted = []
for blockHash in blockmetadb.get_blocks_by_type('pm'): for blockHash in blockmetadb.get_blocks_by_type('pm'):
if blockHash in deleted:
continue
if blockHash in inbox_cache:
inbox_list.append(blockHash)
continue
block = onionrblockapi.Block(blockHash) block = onionrblockapi.Block(blockHash)
block.decrypt() block.decrypt()
if block.decrypted and reconstructhash.deconstruct_hash(blockHash) not in deleted: if block.decrypted and reconstructhash.deconstruct_hash(blockHash):
inbox_cache[blockHash] = True
inbox_list.append(blockHash) inbox_list.append(blockHash)
return inbox_list return inbox_list