rename class

This commit is contained in:
ThomasV 2012-03-17 13:12:16 +01:00
parent 65f208e733
commit e21c463923
2 changed files with 9 additions and 7 deletions

View File

@ -5,7 +5,7 @@ import socket, time, interface
def cb(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")
while True:

View File

@ -210,7 +210,7 @@ class HttpInterface(PollingInterface):
import threading
class TCPInterface(Interface):
class AsynchronousInterface(Interface):
"""json-rpc over persistent TCP connection, asynchronous"""
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':
self.blocks = result
apply(self.newblock_callback,(result,))
if self.newblock_callback: apply(self.newblock_callback,(result,))
else:
print "received message:", c
@ -348,14 +348,16 @@ def new_interface(wallet):
history_cb = wallet.receive_history_callback
if port == 50000:
interface = NativeInterface(host, port, address_cb, history_cb)
InterfaceClass = NativeInterface
elif port == 50001:
interface = TCPInterface(host, port, address_cb, history_cb)
InterfaceClass = AsynchronousInterface
elif port in [80, 81, 8080, 8081]:
interface = HttpInterface(host, port, address_cb, history_cb)
InterfaceClass = HttpInterface
else:
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