Added files for new dandelion++ gossip and transport system
This commit is contained in:
parent
cbd9a3cbec
commit
d388bba646
28
src/gossip/__init__.py
Normal file
28
src/gossip/__init__.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from typing import TYPE_CHECKING
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import queue
|
||||||
|
from onionrblocks import Block
|
||||||
|
|
||||||
|
from onionrthreads import add_onionr_thread
|
||||||
|
"""
|
||||||
|
Onionr uses a flavor of Dandelion++ epidemic routing
|
||||||
|
|
||||||
|
The starter creates a peer set and passes it to the client and server
|
||||||
|
as well as each of the plugins.
|
||||||
|
|
||||||
|
The transports forward incoming requests to the gossip server
|
||||||
|
|
||||||
|
When a new peer announcement is recieved an event is fired and the transport plugin that handles it will (or wont)
|
||||||
|
create a new peer object by connecting to that peer
|
||||||
|
|
||||||
|
When a new block is generated, it is added to a queue in raw form passed to the starter
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def start_gossip_threads(block_queue: queue.Queue[Block]):
|
||||||
|
# Peer set is largely handled by the transport plugins
|
||||||
|
# There is a unified set so gossip logic is not repeated
|
||||||
|
peer_set = set()
|
||||||
|
|
||||||
|
|
0
src/gossip/client.py
Normal file
0
src/gossip/client.py
Normal file
11
src/gossip/peer.py
Normal file
11
src/gossip/peer.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class Peer:
|
||||||
|
def __init__(self):
|
||||||
|
self.stats = {}
|
||||||
|
self.sock = None
|
||||||
|
self.id = ""
|
||||||
|
def send(self, data: bytes):
|
||||||
|
return
|
||||||
|
def disconnect(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
0
src/gossip/server.py
Normal file
0
src/gossip/server.py
Normal file
4
static-data/default-plugins/tor/info.json
Normal file
4
static-data/default-plugins/tor/info.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{ "name": "tor",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"author": "onionr"
|
||||||
|
}
|
44
static-data/default-plugins/tor/main.py
Normal file
44
static-data/default-plugins/tor/main.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
"""Onionr - Private P2P Communication.
|
||||||
|
|
||||||
|
This default plugin handles "flow" messages
|
||||||
|
(global chatroom style communication)
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import locale
|
||||||
|
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
# import after path insert
|
||||||
|
|
||||||
|
"""
|
||||||
|
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/>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
#flask_blueprint = flowapi.flask_blueprint
|
||||||
|
#security_whitelist = ['circles.circlesstatic', 'circles.circlesindex']
|
||||||
|
|
||||||
|
plugin_name = 'tor'
|
||||||
|
PLUGIN_VERSION = '0.0.0'
|
||||||
|
|
||||||
|
|
||||||
|
class OnionrTor:
|
||||||
|
def __init__(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def on_init(api, data=None):
|
||||||
|
print("plugin init")
|
||||||
|
return
|
Loading…
Reference in New Issue
Block a user