-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathsocket.py
executable file
·74 lines (60 loc) · 2.12 KB
/
socket.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from server.methods.transaction import Transaction
from server.methods.general import General
from server.methods.address import Address
from server import subscription
from server import stats
from server import utils
@stats.socket
def GetInfo():
return General.info()
@stats.socket
def EstimateFee():
return General.fee()
@stats.socket
def AddressUnspent(address=None, amount=0):
return Address.unspent(address, amount)
@stats.socket
def AddressBalance(address=None):
return Address.balance(address)
@stats.socket
def AddressHistory(address=None):
return Address.history(address)
@stats.socket
def AddressMempool(address=None):
return Address.mempool(address)
@stats.socket
def AddressMempoolRaw(address=None):
return Address.mempool(address, True)
@stats.socket
def TransactionInfo(thash=None):
return Transaction.info(thash)
@stats.socket
def Broadcast(raw=None):
return Transaction.broadcast(raw)
@stats.socket
def CheckHistory(addresses=[]):
return Address.check(addresses)
@stats.socket
def TransactionBatch(hashes=[]):
result = []
for thash in hashes:
result.append(Transaction.info(thash))
return utils.response(result)
def init(sio):
sio.on_event("connect", subscription.Connect)
sio.on_event("subscribe.address", subscription.SubscribeAddress)
sio.on_event("subscribe.blocks", subscription.SubscribeBlocks)
sio.on_event("unsubscribe.address", subscription.UnubscribeAddress)
sio.on_event("unsubscribe.blocks", subscription.UnsubscribeBlocks)
sio.on_event("disconnect", subscription.Disconnect)
sio.on_event("general.info", GetInfo)
sio.on_event("general.fee", EstimateFee)
sio.on_event("address.unspent", AddressUnspent)
sio.on_event("address.balance", AddressBalance)
sio.on_event("address.history", AddressHistory)
sio.on_event("address.mempool", AddressMempool)
sio.on_event("address.mempool.raw", AddressMempoolRaw)
sio.on_event("address.check", CheckHistory)
sio.on_event("transaction.info", TransactionInfo)
sio.on_event("transaction.broadcast", Broadcast)
sio.on_event("transaction.batch", TransactionBatch)