forked from LBRYCommunity/lbry-sdk
drop old style classes in torba.server
This commit is contained in:
parent
b2bcf39872
commit
9e5246c619
15 changed files with 32 additions and 32 deletions
|
@ -24,7 +24,7 @@ from torba.server.util import chunks, class_logger
|
|||
from torba.server.db import FlushData
|
||||
|
||||
|
||||
class Prefetcher(object):
|
||||
class Prefetcher:
|
||||
'''Prefetches blocks (in the forward direction only).'''
|
||||
|
||||
def __init__(self, daemon, coin, blocks_event):
|
||||
|
@ -143,7 +143,7 @@ class ChainError(Exception):
|
|||
'''Raised on error processing blocks.'''
|
||||
|
||||
|
||||
class BlockProcessor(object):
|
||||
class BlockProcessor:
|
||||
'''Process blocks and update the DB state to match.
|
||||
|
||||
Employ a prefetcher to prefetch blocks in batches for processing.
|
||||
|
|
|
@ -58,7 +58,7 @@ class CoinError(Exception):
|
|||
'''Exception raised for coin-related errors.'''
|
||||
|
||||
|
||||
class Coin(object):
|
||||
class Coin:
|
||||
'''Base class of coin hierarchy.'''
|
||||
|
||||
REORG_LIMIT = 200
|
||||
|
@ -268,7 +268,7 @@ class Coin(object):
|
|||
return h
|
||||
|
||||
|
||||
class AuxPowMixin(object):
|
||||
class AuxPowMixin:
|
||||
STATIC_BLOCK_HEADERS = False
|
||||
DESERIALIZER = lib_tx.DeserializerAuxPow
|
||||
|
||||
|
@ -284,7 +284,7 @@ class AuxPowMixin(object):
|
|||
return deserializer.read_header(height, cls.BASIC_HEADER_SIZE)
|
||||
|
||||
|
||||
class EquihashMixin(object):
|
||||
class EquihashMixin:
|
||||
STATIC_BLOCK_HEADERS = False
|
||||
BASIC_HEADER_SIZE = 140 # Excluding Equihash solution
|
||||
DESERIALIZER = lib_tx.DeserializerEquihash
|
||||
|
@ -311,7 +311,7 @@ class EquihashMixin(object):
|
|||
return deserializer.read_header(height, cls.BASIC_HEADER_SIZE)
|
||||
|
||||
|
||||
class ScryptMixin(object):
|
||||
class ScryptMixin:
|
||||
|
||||
DESERIALIZER = lib_tx.DeserializerTxTime
|
||||
HEADER_HASH = None
|
||||
|
@ -330,7 +330,7 @@ class ScryptMixin(object):
|
|||
return cls.HEADER_HASH(header)
|
||||
|
||||
|
||||
class KomodoMixin(object):
|
||||
class KomodoMixin:
|
||||
P2PKH_VERBYTE = bytes.fromhex("3C")
|
||||
P2SH_VERBYTES = [bytes.fromhex("55")]
|
||||
WIF_BYTE = bytes.fromhex("BC")
|
||||
|
@ -339,7 +339,7 @@ class KomodoMixin(object):
|
|||
DESERIALIZER = lib_tx.DeserializerZcash
|
||||
|
||||
|
||||
class BitcoinMixin(object):
|
||||
class BitcoinMixin:
|
||||
SHORTNAME = "BTC"
|
||||
NET = "mainnet"
|
||||
XPUB_VERBYTES = bytes.fromhex("0488b21e")
|
||||
|
@ -524,7 +524,7 @@ class Emercoin(Coin):
|
|||
return double_sha256(header[:cls.BASIC_HEADER_SIZE])
|
||||
|
||||
|
||||
class BitcoinTestnetMixin(object):
|
||||
class BitcoinTestnetMixin:
|
||||
SHORTNAME = "XTN"
|
||||
NET = "testnet"
|
||||
XPUB_VERBYTES = bytes.fromhex("043587cf")
|
||||
|
|
|
@ -37,7 +37,7 @@ class WorkQueueFullError(Exception):
|
|||
'''Internal - when the daemon's work queue is full.'''
|
||||
|
||||
|
||||
class Daemon(object):
|
||||
class Daemon:
|
||||
'''Handles connections to a daemon at the given URL.'''
|
||||
|
||||
WARMING_UP = -28
|
||||
|
|
|
@ -33,7 +33,7 @@ UTXO = namedtuple("UTXO", "tx_num tx_pos tx_hash height value")
|
|||
|
||||
|
||||
@attr.s(slots=True)
|
||||
class FlushData(object):
|
||||
class FlushData:
|
||||
height = attr.ib()
|
||||
tx_count = attr.ib()
|
||||
headers = attr.ib()
|
||||
|
@ -45,7 +45,7 @@ class FlushData(object):
|
|||
tip = attr.ib()
|
||||
|
||||
|
||||
class DB(object):
|
||||
class DB:
|
||||
'''Simple wrapper of the backend database for querying.
|
||||
|
||||
Performs no DB update, though the DB will be cleaned on opening if
|
||||
|
|
|
@ -84,7 +84,7 @@ class Base58Error(Exception):
|
|||
'''Exception used for Base58 errors.'''
|
||||
|
||||
|
||||
class Base58(object):
|
||||
class Base58:
|
||||
'''Class providing base 58 functionality.'''
|
||||
|
||||
chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||
|
|
|
@ -20,7 +20,7 @@ from torba.server.util import pack_be_uint16, unpack_be_uint16_from
|
|||
from torba.server.hash import hash_to_hex_str, HASHX_LEN
|
||||
|
||||
|
||||
class History(object):
|
||||
class History:
|
||||
|
||||
DB_VERSIONS = [0]
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ from torba.server.db import UTXO
|
|||
|
||||
|
||||
@attr.s(slots=True)
|
||||
class MemPoolTx(object):
|
||||
class MemPoolTx:
|
||||
prevouts = attr.ib()
|
||||
# A pair is a (hashX, value) tuple
|
||||
in_pairs = attr.ib()
|
||||
|
@ -32,7 +32,7 @@ class MemPoolTx(object):
|
|||
|
||||
|
||||
@attr.s(slots=True)
|
||||
class MemPoolTxSummary(object):
|
||||
class MemPoolTxSummary:
|
||||
hash = attr.ib()
|
||||
fee = attr.ib()
|
||||
has_unconfirmed_inputs = attr.ib()
|
||||
|
@ -79,7 +79,7 @@ class MemPoolAPI(ABC):
|
|||
daemon's height at the time the mempool was obtained.'''
|
||||
|
||||
|
||||
class MemPool(object):
|
||||
class MemPool:
|
||||
'''Representation of the daemon's mempool.
|
||||
|
||||
coin - a coin class from coins.py
|
||||
|
|
|
@ -33,7 +33,7 @@ from aiorpcx import Event
|
|||
from torba.server.hash import double_sha256
|
||||
|
||||
|
||||
class Merkle(object):
|
||||
class Merkle:
|
||||
'''Perform merkle tree calculations on binary hashes using a given hash
|
||||
function.
|
||||
|
||||
|
@ -157,7 +157,7 @@ class Merkle(object):
|
|||
return leaf_branch + level_branch, root
|
||||
|
||||
|
||||
class MerkleCache(object):
|
||||
class MerkleCache:
|
||||
'''A cache to calculate merkle branches efficiently.'''
|
||||
|
||||
def __init__(self, merkle, source_func):
|
||||
|
|
|
@ -33,7 +33,7 @@ from torba.server.util import cachedproperty
|
|||
from typing import Dict
|
||||
|
||||
|
||||
class Peer(object):
|
||||
class Peer:
|
||||
|
||||
# Protocol version
|
||||
ATTRS = ('host', 'features',
|
||||
|
|
|
@ -49,7 +49,7 @@ class PeerSession(RPCSession):
|
|||
await handler_invocation(None, request) # Raises
|
||||
|
||||
|
||||
class PeerManager(object):
|
||||
class PeerManager:
|
||||
'''Looks after the DB of peer network servers.
|
||||
|
||||
Attempts to maintain a connection with up to 8 peers.
|
||||
|
|
|
@ -91,7 +91,7 @@ def _match_ops(ops, pattern):
|
|||
return True
|
||||
|
||||
|
||||
class ScriptPubKey(object):
|
||||
class ScriptPubKey:
|
||||
'''A class for handling a tx output script that gives conditions
|
||||
necessary for spending.
|
||||
'''
|
||||
|
@ -177,7 +177,7 @@ class ScriptPubKey(object):
|
|||
+ bytes([OP_1 + n - 1, OP_CHECK_MULTISIG]))
|
||||
|
||||
|
||||
class Script(object):
|
||||
class Script:
|
||||
|
||||
@classmethod
|
||||
def get_ops(cls, script):
|
||||
|
|
|
@ -79,7 +79,7 @@ def assert_tx_hash(value):
|
|||
raise RPCError(BAD_REQUEST, f'{value} should be a transaction hash')
|
||||
|
||||
|
||||
class Semaphores(object):
|
||||
class Semaphores:
|
||||
'''For aiorpcX's semaphore handling.'''
|
||||
|
||||
def __init__(self, semaphores):
|
||||
|
@ -96,7 +96,7 @@ class Semaphores(object):
|
|||
semaphore.release()
|
||||
|
||||
|
||||
class SessionGroup(object):
|
||||
class SessionGroup:
|
||||
|
||||
def __init__(self, gid):
|
||||
self.gid = gid
|
||||
|
@ -104,7 +104,7 @@ class SessionGroup(object):
|
|||
self.semaphore = asyncio.Semaphore(20)
|
||||
|
||||
|
||||
class SessionManager(object):
|
||||
class SessionManager:
|
||||
'''Holds global state about all sessions.'''
|
||||
|
||||
def __init__(self, env, db, bp, daemon, mempool, shutdown_event):
|
||||
|
|
|
@ -22,7 +22,7 @@ def db_class(name):
|
|||
raise RuntimeError('unrecognised DB engine "{}"'.format(name))
|
||||
|
||||
|
||||
class Storage(object):
|
||||
class Storage:
|
||||
'''Abstract base class of the DB backend abstraction.'''
|
||||
|
||||
def __init__(self, name, for_sync):
|
||||
|
@ -121,7 +121,7 @@ class RocksDB(Storage):
|
|||
return RocksDBIterator(self.db, prefix, reverse)
|
||||
|
||||
|
||||
class RocksDBWriteBatch(object):
|
||||
class RocksDBWriteBatch:
|
||||
'''A write batch for RocksDB.'''
|
||||
|
||||
def __init__(self, db):
|
||||
|
@ -136,7 +136,7 @@ class RocksDBWriteBatch(object):
|
|||
self.db.write(self.batch)
|
||||
|
||||
|
||||
class RocksDBIterator(object):
|
||||
class RocksDBIterator:
|
||||
'''An iterator for RocksDB.'''
|
||||
|
||||
def __init__(self, db, prefix, reverse):
|
||||
|
|
|
@ -85,7 +85,7 @@ class TxOutput(namedtuple("TxOutput", "value pk_script")):
|
|||
))
|
||||
|
||||
|
||||
class Deserializer(object):
|
||||
class Deserializer:
|
||||
'''Deserializes blocks into transactions.
|
||||
|
||||
External entry points are read_tx(), read_tx_and_hash(),
|
||||
|
|
|
@ -70,7 +70,7 @@ def class_logger(path, classname):
|
|||
# Method decorator. To be used for calculations that will always
|
||||
# deliver the same result. The method cannot take any arguments
|
||||
# and should be accessed as an attribute.
|
||||
class cachedproperty(object):
|
||||
class cachedproperty:
|
||||
|
||||
def __init__(self, f):
|
||||
self.f = f
|
||||
|
@ -178,7 +178,7 @@ def increment_byte_string(bs):
|
|||
return None
|
||||
|
||||
|
||||
class LogicalFile(object):
|
||||
class LogicalFile:
|
||||
'''A logical binary file split across several separate files on disk.'''
|
||||
|
||||
def __init__(self, prefix, digits, file_size):
|
||||
|
|
Loading…
Reference in a new issue