Some further cleanup
This commit is contained in:
parent
885872f0b5
commit
1f3e942cbc
13
lib/coins.py
13
lib/coins.py
@ -42,8 +42,7 @@ from lib.script import ScriptPubKey
|
|||||||
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, \
|
from lib.tx import Deserializer, DeserializerSegWit, DeserializerAuxPow, \
|
||||||
DeserializerZcash, DeserializerTxTime, DeserializerReddcoin
|
DeserializerZcash, DeserializerTxTime, DeserializerReddcoin
|
||||||
from server.block_processor import BlockProcessor
|
from server.block_processor import BlockProcessor
|
||||||
from server.daemon import Daemon, DashDaemon, LegacyRPCDaemon,\
|
import server.daemon as daemon
|
||||||
FakeEstimateFeeDaemon
|
|
||||||
from server.session import ElectrumX, DashElectrumX
|
from server.session import ElectrumX, DashElectrumX
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ class Coin(object):
|
|||||||
STATIC_BLOCK_HEADERS = True
|
STATIC_BLOCK_HEADERS = True
|
||||||
SESSIONCLS = ElectrumX
|
SESSIONCLS = ElectrumX
|
||||||
DESERIALIZER = Deserializer
|
DESERIALIZER = Deserializer
|
||||||
DAEMON = Daemon
|
DAEMON = daemon.Daemon
|
||||||
BLOCK_PROCESSOR = BlockProcessor
|
BLOCK_PROCESSOR = BlockProcessor
|
||||||
XPUB_VERBYTES = bytes('????', 'utf-8')
|
XPUB_VERBYTES = bytes('????', 'utf-8')
|
||||||
XPRV_VERBYTES = bytes('????', 'utf-8')
|
XPRV_VERBYTES = bytes('????', 'utf-8')
|
||||||
@ -612,7 +611,7 @@ class Dash(Coin):
|
|||||||
'wl4sfwq2hwxnodof.onion s t',
|
'wl4sfwq2hwxnodof.onion s t',
|
||||||
]
|
]
|
||||||
SESSIONCLS = DashElectrumX
|
SESSIONCLS = DashElectrumX
|
||||||
DAEMON = DashDaemon
|
DAEMON = daemon.DashDaemon
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def header_hash(cls, header):
|
def header_hash(cls, header):
|
||||||
@ -814,7 +813,7 @@ class Blackcoin(Coin):
|
|||||||
GENESIS_HASH = ('000001faef25dec4fbcf906e6242621d'
|
GENESIS_HASH = ('000001faef25dec4fbcf906e6242621d'
|
||||||
'f2c183bf232f263d0ba5b101911e4563')
|
'f2c183bf232f263d0ba5b101911e4563')
|
||||||
DESERIALIZER = DeserializerTxTime
|
DESERIALIZER = DeserializerTxTime
|
||||||
DAEMON = LegacyRPCDaemon
|
DAEMON = daemon.LegacyRPCDaemon
|
||||||
TX_COUNT = 4594999
|
TX_COUNT = 4594999
|
||||||
TX_COUNT_HEIGHT = 1667070
|
TX_COUNT_HEIGHT = 1667070
|
||||||
TX_PER_BLOCK = 3
|
TX_PER_BLOCK = 3
|
||||||
@ -848,7 +847,7 @@ class Peercoin(Coin):
|
|||||||
GENESIS_HASH = ('0000000032fe677166d54963b62a4677'
|
GENESIS_HASH = ('0000000032fe677166d54963b62a4677'
|
||||||
'd8957e87c508eaa4fd7eb1c880cd27e3')
|
'd8957e87c508eaa4fd7eb1c880cd27e3')
|
||||||
DESERIALIZER = DeserializerTxTime
|
DESERIALIZER = DeserializerTxTime
|
||||||
DAEMON = LegacyRPCDaemon
|
DAEMON = daemon.LegacyRPCDaemon
|
||||||
TX_COUNT = 1207356
|
TX_COUNT = 1207356
|
||||||
TX_COUNT_HEIGHT = 306425
|
TX_COUNT_HEIGHT = 306425
|
||||||
TX_PER_BLOCK = 4
|
TX_PER_BLOCK = 4
|
||||||
@ -950,7 +949,7 @@ class Fujicoin(Coin):
|
|||||||
'a636f70856183086842667a1597714a0')
|
'a636f70856183086842667a1597714a0')
|
||||||
ESTIMATE_FEE = 0.001
|
ESTIMATE_FEE = 0.001
|
||||||
RELAY_FEE = 0.001
|
RELAY_FEE = 0.001
|
||||||
DAEMON = FakeEstimateFeeDaemon
|
DAEMON = daemon.FakeEstimateFeeDaemon
|
||||||
TX_COUNT = 170478
|
TX_COUNT = 170478
|
||||||
TX_COUNT_HEIGHT = 1521676
|
TX_COUNT_HEIGHT = 1521676
|
||||||
TX_PER_BLOCK = 1
|
TX_PER_BLOCK = 1
|
||||||
|
|||||||
@ -47,8 +47,7 @@ class Controller(util.LoggedClass):
|
|||||||
self.loop.set_default_executor(self.executor)
|
self.loop.set_default_executor(self.executor)
|
||||||
self.start_time = time.time()
|
self.start_time = time.time()
|
||||||
self.coin = env.coin
|
self.coin = env.coin
|
||||||
self.daemon = self.coin.DAEMON(self.coin,
|
self.daemon = self.coin.DAEMON(env)
|
||||||
env.coin.daemon_urls(env.daemon_url))
|
|
||||||
self.bp = self.coin.BLOCK_PROCESSOR(env, self, self.daemon)
|
self.bp = self.coin.BLOCK_PROCESSOR(env, self, self.daemon)
|
||||||
self.mempool = MemPool(self.bp, self)
|
self.mempool = MemPool(self.bp, self)
|
||||||
self.peer_mgr = PeerManager(env, self)
|
self.peer_mgr = PeerManager(env, self)
|
||||||
|
|||||||
@ -34,10 +34,10 @@ class Daemon(util.LoggedClass):
|
|||||||
class DaemonWarmingUpError(Exception):
|
class DaemonWarmingUpError(Exception):
|
||||||
'''Raised when the daemon returns an error in its results.'''
|
'''Raised when the daemon returns an error in its results.'''
|
||||||
|
|
||||||
def __init__(self, coin, urls):
|
def __init__(self, env):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.coin = coin
|
self.coin = env.coin
|
||||||
self.set_urls(urls)
|
self.set_urls(env.coin.daemon_urls(env.daemon_url))
|
||||||
self._height = None
|
self._height = None
|
||||||
self._mempool_hashes = set()
|
self._mempool_hashes = set()
|
||||||
self.mempool_refresh_event = asyncio.Event()
|
self.mempool_refresh_event = asyncio.Event()
|
||||||
@ -264,7 +264,9 @@ class Daemon(util.LoggedClass):
|
|||||||
If the daemon has not been queried yet this returns None.'''
|
If the daemon has not been queried yet this returns None.'''
|
||||||
return self._height
|
return self._height
|
||||||
|
|
||||||
|
|
||||||
class DashDaemon(Daemon):
|
class DashDaemon(Daemon):
|
||||||
|
|
||||||
async def masternode_broadcast(self, params):
|
async def masternode_broadcast(self, params):
|
||||||
'''Broadcast a transaction to the network.'''
|
'''Broadcast a transaction to the network.'''
|
||||||
return await self._send_single('masternodebroadcast', params)
|
return await self._send_single('masternodebroadcast', params)
|
||||||
@ -273,9 +275,11 @@ class DashDaemon(Daemon):
|
|||||||
'''Return the masternode status.'''
|
'''Return the masternode status.'''
|
||||||
return await self._send_single('masternodelist', params)
|
return await self._send_single('masternodelist', params)
|
||||||
|
|
||||||
|
|
||||||
class FakeEstimateFeeDaemon(Daemon):
|
class FakeEstimateFeeDaemon(Daemon):
|
||||||
'''Daemon that simulates estimatefee and relayfee RPC calls. Coin that
|
'''Daemon that simulates estimatefee and relayfee RPC calls. Coin that
|
||||||
wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE'''
|
wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE'''
|
||||||
|
|
||||||
async def estimatefee(self, params):
|
async def estimatefee(self, params):
|
||||||
'''Return the fee estimate for the given parameters.'''
|
'''Return the fee estimate for the given parameters.'''
|
||||||
return self.coin.ESTIMATE_FEE
|
return self.coin.ESTIMATE_FEE
|
||||||
@ -285,6 +289,7 @@ class FakeEstimateFeeDaemon(Daemon):
|
|||||||
to the daemon's memory pool.'''
|
to the daemon's memory pool.'''
|
||||||
return self.coin.RELAY_FEE
|
return self.coin.RELAY_FEE
|
||||||
|
|
||||||
|
|
||||||
class LegacyRPCDaemon(Daemon):
|
class LegacyRPCDaemon(Daemon):
|
||||||
'''Handles connections to a daemon at the given URL.
|
'''Handles connections to a daemon at the given URL.
|
||||||
|
|
||||||
@ -294,7 +299,6 @@ class LegacyRPCDaemon(Daemon):
|
|||||||
as in the underlying blockchain but it is good enough for our indexing
|
as in the underlying blockchain but it is good enough for our indexing
|
||||||
purposes.'''
|
purposes.'''
|
||||||
|
|
||||||
|
|
||||||
async def raw_blocks(self, hex_hashes):
|
async def raw_blocks(self, hex_hashes):
|
||||||
'''Return the raw binary blocks with the given hex hashes.'''
|
'''Return the raw binary blocks with the given hex hashes.'''
|
||||||
params_iterable = ((h, ) for h in hex_hashes)
|
params_iterable = ((h, ) for h in hex_hashes)
|
||||||
@ -340,4 +344,6 @@ class LegacyRPCDaemon(Daemon):
|
|||||||
return raw_block
|
return raw_block
|
||||||
|
|
||||||
def timestamp_safe(self, t):
|
def timestamp_safe(self, t):
|
||||||
return t if isinstance(t, int) else timegm(strptime(t, "%Y-%m-%d %H:%M:%S %Z"))
|
if isinstance(t, int):
|
||||||
|
return t
|
||||||
|
return timegm(strptime(t, "%Y-%m-%d %H:%M:%S %Z"))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user