logging level fixes to make output less spammy about connection blips

This commit is contained in:
Kevin F 2023-01-23 16:20:03 -06:00
parent db59a198f5
commit 0236fc83f4
8 changed files with 38 additions and 13 deletions

View File

@ -22,6 +22,8 @@ def _do_ask_peer(peer):
_ask_peer(peer)
except TimeoutError:
logging.debug("Timed out when asking for new peers")
except ConnectionError:
pass
except Exception:
logging.error(format_exc())

View File

@ -11,8 +11,8 @@ def connect_peer(peer):
try:
s = peer.get_socket(120)
except Exception:
logging.warn(f"Could not connect to {peer.transport_address}")
logging.warn(traceback.format_exc())
logging.debug(f"Could not connect to {peer.transport_address}")
logging.debug(traceback.format_exc())
else:
with s:
s.sendall(command_to_byte(GossipCommands.PING))

View File

@ -88,7 +88,7 @@ def gossip_server():
try:
await diffuse_blocks(reader, writer)
except Exception:
logging.warn(
logging.debug(
f"Err streaming blocks\n{traceback.format_exc()}",
)
case GossipCommands.PUT_BLOCKS:

View File

@ -6,13 +6,17 @@ import sys
import os
import locale
from time import sleep
import base64
from logger import log as logging
from typing import Set, TYPE_CHECKING
import onionrplugins
import requests
import requests_unixsocket
import blockdb
from gossip.peerset import gossip_peer_set
import onionrblocks
import config
locale.setlocale(locale.LC_ALL, '')
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
@ -37,9 +41,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
plugin_name = 'example'
PLUGIN_VERSION = '0.0.0'
rpc_payload_template = {
"method": "echo",
"params": ["example"],
"jsonrpc": "2.0",
"id": 0,
}
def on_blocktest_cmd(api, data=None):
bl = onionrblocks.create_anonvdf_block(input("Enter a message:").encode('utf-8'), b"tst", 3600)
message = base64.b64encode(input("Enter a message ").encode('utf-8')).decode('utf-8')
payload = rpc_payload_template
payload['method'] = 'create_and_insert_block'
payload['params'] = [message, "tst", 3600, {}]
req = onionrplugins.pluginapis.plugin_apis['rpc.rpc_client'](json=payload).text
print(req)
def on_printtest_cmd(api, data=None):

View File

@ -1,7 +1,9 @@
from secrets import randbits
import base64
from typing import Union
import ujson
from onionrblocks import Block
import onionrblocks
from jsonrpc import dispatcher
@ -28,8 +30,7 @@ def get_blocks(timestamp):
return blocks
@dispatcher.add_method
def create_block(
def _do_create_block(
block_data: 'base64', block_type: str, ttl: int, metadata: dict):
# Wrapper for onionrblocks.create_block
# (take base64 to be compatible with RPC)
@ -51,14 +52,19 @@ def create_block(
}
return bl_json
@dispatcher.add_method
def create_block(
block_data: 'base64', block_type: str, ttl: int, metadata: dict):
return _do_create_block(block_data, block_type, ttl, metadata)
@dispatcher.add_method
def create_and_insert_block(
block_data: 'base64',
block_type: str, ttl: int, metadata: dict) -> str:
bl = create_block(block_data, block_type, ttl, metadata)['id']
bl = _do_create_block(block_data, block_type, ttl, metadata)['id']
insert_block(bl)
return bl['id']
return bl
# As per dandelion++ spec the edge should be the same.

View File

@ -0,0 +1 @@
iub5tjg3iu23btf7depeohyefv3n52izqcomprrrn72hvlrnvp5fjlyd,diqljvlqppawyki3lo2emh3sibvhflmn7d736gqcr5m6obrnfn6cytyd

View File

@ -1,6 +1,6 @@
"""Onionr - Private P2P Communication.
Unix transport plugin. Intended for testing Onionr networks using IPC
Unix transport plugin. Intended for testing Onionr without actual network traffic.
"""
import sys
import os