rename class
This commit is contained in:
parent
65f208e733
commit
e21c463923
|
@ -5,7 +5,7 @@ import socket, time, interface
|
||||||
def cb(block_number):
|
def cb(block_number):
|
||||||
print block_number
|
print block_number
|
||||||
|
|
||||||
i = interface.TCPInterface('ecdsa.org', 50001, newblock_callback=cb)
|
i = interface.AsynchronousInterface('ecdsa.org', 50001, newblock_callback=cb)
|
||||||
i.start_session([],"blocks")
|
i.start_session([],"blocks")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -210,7 +210,7 @@ class HttpInterface(PollingInterface):
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
class TCPInterface(Interface):
|
class AsynchronousInterface(Interface):
|
||||||
"""json-rpc over persistent TCP connection, asynchronous"""
|
"""json-rpc over persistent TCP connection, asynchronous"""
|
||||||
|
|
||||||
def __init__(self, host, port, address_callback=None, history_callback=None, newblock_callback=None):
|
def __init__(self, host, port, address_callback=None, history_callback=None, newblock_callback=None):
|
||||||
|
@ -287,7 +287,7 @@ class TCPInterface(Interface):
|
||||||
|
|
||||||
elif method == 'numblocks.subscribe':
|
elif method == 'numblocks.subscribe':
|
||||||
self.blocks = result
|
self.blocks = result
|
||||||
apply(self.newblock_callback,(result,))
|
if self.newblock_callback: apply(self.newblock_callback,(result,))
|
||||||
else:
|
else:
|
||||||
print "received message:", c
|
print "received message:", c
|
||||||
|
|
||||||
|
@ -348,14 +348,16 @@ def new_interface(wallet):
|
||||||
history_cb = wallet.receive_history_callback
|
history_cb = wallet.receive_history_callback
|
||||||
|
|
||||||
if port == 50000:
|
if port == 50000:
|
||||||
interface = NativeInterface(host, port, address_cb, history_cb)
|
InterfaceClass = NativeInterface
|
||||||
elif port == 50001:
|
elif port == 50001:
|
||||||
interface = TCPInterface(host, port, address_cb, history_cb)
|
InterfaceClass = AsynchronousInterface
|
||||||
elif port in [80, 81, 8080, 8081]:
|
elif port in [80, 81, 8080, 8081]:
|
||||||
interface = HttpInterface(host, port, address_cb, history_cb)
|
InterfaceClass = HttpInterface
|
||||||
else:
|
else:
|
||||||
print "unknown port number: %d. using native protocol."%port
|
print "unknown port number: %d. using native protocol."%port
|
||||||
interface = NativeInterface(host, port, address_cb, history_cb)
|
InterfaceClass = NativeInterface
|
||||||
|
|
||||||
|
interface = InterfaceClass(host, port, address_cb, history_cb)
|
||||||
|
|
||||||
return interface
|
return interface
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue