1
0

aiorpcx: socks support

This commit is contained in:
Janus
2018-08-27 20:39:36 +02:00
committed by SomberNight
parent c53caecd1e
commit f733cb8947
5 changed files with 77 additions and 35 deletions

View File

@@ -38,6 +38,7 @@ from locale import localeconv
from .i18n import _
from aiorpcx import ClientSession, Notification
import urllib.request, urllib.parse, urllib.error
import queue
@@ -947,3 +948,24 @@ VerifiedTxInfo = NamedTuple("VerifiedTxInfo", [("height", int),
("timestamp", int),
("txpos", int),
("header_hash", str)])
from .blockchain import deserialize_header
class NotificationSession(ClientSession):
def __init__(self, scripthash, header, *args, **kwargs):
super(NotificationSession, self).__init__(*args, **kwargs)
self.scripthash = scripthash
self.header = header
@aiosafe
async def handle_request(self, request):
if isinstance(request, Notification):
if request.method == 'blockchain.scripthash.subscribe' and self.scripthash is not None:
args = request.args
await self.scripthash.put((args[0], args[1]))
elif request.method == 'blockchain.headers.subscribe' and self.header is not None:
deser = deserialize_header(bfh(request.args[0]['hex']), request.args[0]['height'])
await self.header.put(deser)
else:
assert False, request.method