use fp symbol instead, merge master changes before merging back to improve circles
This commit is contained in:
commit
0059c91b06
12 changed files with 107 additions and 15 deletions
|
@ -15,7 +15,6 @@ import onionrcrypto
|
|||
from communicator import onlinepeers
|
||||
if TYPE_CHECKING:
|
||||
from communicator import OnionrCommunicatorDaemon
|
||||
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -43,6 +43,7 @@ DATABASE_LOCK_TIMEOUT = 60
|
|||
|
||||
# Block creation anonymization requirements
|
||||
MIN_BLOCK_UPLOAD_PEER_PERCENT = 0.1
|
||||
MIN_SHARE_WAIT_DELAY_SECS = 5
|
||||
|
||||
WSGI_SERVER_REQUEST_TIMEOUT_SECS = 120
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import os
|
|||
import subprocess
|
||||
|
||||
from flask import Response, Blueprint, request, send_from_directory, abort
|
||||
from gevent import spawn
|
||||
from gevent import sleep
|
||||
import unpaddedbase32
|
||||
|
||||
from httpapi import apiutils
|
||||
|
@ -71,8 +73,8 @@ class PrivateEndpoints:
|
|||
raise ValueError('block hash needs to be alpha numeric')
|
||||
name = reconstructhash.reconstruct_hash(name)
|
||||
if name in client_api.publicAPI.hideBlocks:
|
||||
client_api.publicAPI.hideBlocks.remove(name)
|
||||
return Response("removed")
|
||||
spawn(_delay_wait_for_share_block_removal)
|
||||
return Response("will be removed")
|
||||
else:
|
||||
client_api.publicAPI.hideBlocks.append(name)
|
||||
return Response("added")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from . import insert
|
||||
from .insert import time_insert
|
||||
|
||||
insert = insert.insert_block
|
||||
insert = insert.insert_block
|
||||
time_insert = time_insert
|
4
src/onionrblocks/insert/__init__.py
Normal file
4
src/onionrblocks/insert/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
from . import main, timeinsert
|
||||
|
||||
insert_block = main.insert_block
|
||||
time_insert = timeinsert.time_insert
|
|
@ -24,7 +24,7 @@ from gevent import spawn
|
|||
|
||||
from onionrutils import bytesconverter, epoch
|
||||
import filepaths, onionrstorage
|
||||
from . import storagecounter
|
||||
from .. import storagecounter
|
||||
from onionrplugins import onionrevents as events
|
||||
from etc import powchoice, onionrvalues
|
||||
import config, onionrcrypto as crypto, onionrexceptions
|
51
src/onionrblocks/insert/timeinsert.py
Normal file
51
src/onionrblocks/insert/timeinsert.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
"""Onionr - Private P2P Communication.
|
||||
|
||||
Wrapper to insert blocks with variable delay
|
||||
"""
|
||||
from . import main
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
def time_insert(*args, **kwargs):
|
||||
"""Block insert wrapper to allow for insertions independent of mixmate.
|
||||
|
||||
Takes exact args as insert_block, with additional keyword:
|
||||
delay=n; where n=seconds to tell initial nodes to delay share for.
|
||||
|
||||
defaults to 0 or previously set value in current block meta
|
||||
"""
|
||||
try:
|
||||
kwargs['meta']
|
||||
except KeyError:
|
||||
kwargs['meta'] = {}
|
||||
|
||||
try:
|
||||
delay = int(kwargs['meta']['dly'])
|
||||
except KeyError:
|
||||
delay = 0
|
||||
try:
|
||||
delay = kwargs['delay']
|
||||
del kwargs['delay']
|
||||
except KeyError:
|
||||
delay = 0
|
||||
|
||||
# Ensure delay >=0
|
||||
if delay < 0:
|
||||
raise ValueError('delay cannot be less than 0')
|
||||
|
||||
kwargs['meta']['dly'] = delay
|
||||
|
||||
return main.insert_block(*args, **kwargs)
|
Loading…
Add table
Add a link
Reference in a new issue