diff --git a/src/gossip/client/peerexchange.py b/src/gossip/client/peerexchange.py
index 25b55fdd..6fbbdd2e 100644
--- a/src/gossip/client/peerexchange.py
+++ b/src/gossip/client/peerexchange.py
@@ -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())
diff --git a/src/gossip/connectpeer.py b/src/gossip/connectpeer.py
index be7fc64e..dcf2a247 100644
--- a/src/gossip/connectpeer.py
+++ b/src/gossip/connectpeer.py
@@ -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))
diff --git a/src/gossip/server/__init__.py b/src/gossip/server/__init__.py
index 0d29fdf5..51cd301f 100644
--- a/src/gossip/server/__init__.py
+++ b/src/gossip/server/__init__.py
@@ -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:
diff --git a/static-data/official-plugins/example/main.py b/static-data/official-plugins/example/main.py
index db4c6491..004ee027 100644
--- a/static-data/official-plugins/example/main.py
+++ b/static-data/official-plugins/example/main.py
@@ -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 .
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):
diff --git a/static-data/official-plugins/rpc/rpc/blocks/__init__.py b/static-data/official-plugins/rpc/rpc/blocks/__init__.py
index ea3a72fa..145c9504 100644
--- a/static-data/official-plugins/rpc/rpc/blocks/__init__.py
+++ b/static-data/official-plugins/rpc/rpc/blocks/__init__.py
@@ -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.
diff --git a/static-data/official-plugins/tor/bootstrap.txt b/static-data/official-plugins/tor/bootstrap.txt
index e69de29b..47bf5e2c 100644
--- a/static-data/official-plugins/tor/bootstrap.txt
+++ b/static-data/official-plugins/tor/bootstrap.txt
@@ -0,0 +1 @@
+iub5tjg3iu23btf7depeohyefv3n52izqcomprrrn72hvlrnvp5fjlyd,diqljvlqppawyki3lo2emh3sibvhflmn7d736gqcr5m6obrnfn6cytyd
\ No newline at end of file
diff --git a/static-data/official-plugins/unixtransport/main.py b/static-data/official-plugins/unixtransport/main.py
index 3aa70638..fa8af13f 100644
--- a/static-data/official-plugins/unixtransport/main.py
+++ b/static-data/official-plugins/unixtransport/main.py
@@ -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
diff --git a/static-data/official-plugins/wot/main.py b/static-data/official-plugins/wot/main.py
index d520cadf..8acc242d 100644
--- a/static-data/official-plugins/wot/main.py
+++ b/static-data/official-plugins/wot/main.py
@@ -80,7 +80,7 @@ def on_init(api, data=None):
except IndexError:
script = ''
logging.info(
- f"Generate a web of trust identity with '{script}wot new" +
+ f"Generate a web of trust identity with '{script}wot new " +
"' and restart Onionr")
return