pylint and mypy fixes
This commit is contained in:
parent
133a86cd89
commit
df251def26
6 changed files with 16 additions and 16 deletions
|
@ -27,4 +27,5 @@ disable=
|
||||||
too-many-arguments,
|
too-many-arguments,
|
||||||
too-many-public-methods,
|
too-many-public-methods,
|
||||||
too-many-instance-attributes,
|
too-many-instance-attributes,
|
||||||
protected-access
|
protected-access,
|
||||||
|
unused-argument
|
||||||
|
|
|
@ -27,7 +27,7 @@ class BaseHeaders:
|
||||||
chunk_size: int
|
chunk_size: int
|
||||||
|
|
||||||
max_target: int
|
max_target: int
|
||||||
genesis_hash: bytes
|
genesis_hash: Optional[bytes]
|
||||||
target_timespan: int
|
target_timespan: int
|
||||||
|
|
||||||
validate_difficulty: bool = True
|
validate_difficulty: bool = True
|
||||||
|
@ -36,7 +36,7 @@ class BaseHeaders:
|
||||||
if path == ':memory:':
|
if path == ':memory:':
|
||||||
self.io = BytesIO()
|
self.io = BytesIO()
|
||||||
self.path = path
|
self.path = path
|
||||||
self._size = None
|
self._size: Optional[int] = None
|
||||||
self._on_change_controller = StreamController()
|
self._on_change_controller = StreamController()
|
||||||
self.on_changed = self._on_change_controller.stream
|
self.on_changed = self._on_change_controller.stream
|
||||||
self._header_connect_lock = defer.DeferredLock()
|
self._header_connect_lock = defer.DeferredLock()
|
||||||
|
@ -61,7 +61,8 @@ class BaseHeaders:
|
||||||
def get_next_chunk_target(self, chunk: int) -> ArithUint256:
|
def get_next_chunk_target(self, chunk: int) -> ArithUint256:
|
||||||
return ArithUint256(self.max_target)
|
return ArithUint256(self.max_target)
|
||||||
|
|
||||||
def get_next_block_target(self, chunk_target: ArithUint256, previous: Optional[dict],
|
@staticmethod
|
||||||
|
def get_next_block_target(chunk_target: ArithUint256, previous: Optional[dict],
|
||||||
current: Optional[dict]) -> ArithUint256:
|
current: Optional[dict]) -> ArithUint256:
|
||||||
return chunk_target
|
return chunk_target
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from torba import baseaccount
|
||||||
from torba import basenetwork
|
from torba import basenetwork
|
||||||
from torba import basetransaction
|
from torba import basetransaction
|
||||||
from torba.basedatabase import BaseDatabase
|
from torba.basedatabase import BaseDatabase
|
||||||
from torba.baseheader import BaseHeaders, InvalidHeader
|
from torba.baseheader import BaseHeaders
|
||||||
from torba.coinselection import CoinSelector
|
from torba.coinselection import CoinSelector
|
||||||
from torba.constants import COIN, NULL_HASH32
|
from torba.constants import COIN, NULL_HASH32
|
||||||
from torba.stream import StreamController
|
from torba.stream import StreamController
|
||||||
|
|
|
@ -8,8 +8,8 @@ __electrumx__ = 'electrumx.lib.coins.BitcoinCashRegtest'
|
||||||
|
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
from torba.baseledger import BaseLedger
|
from torba.baseledger import BaseLedger
|
||||||
from torba.baseheader import BaseHeaders
|
|
||||||
from torba.basetransaction import BaseTransaction
|
from torba.basetransaction import BaseTransaction
|
||||||
|
from .bitcoinsegwit import MainHeaders, UnverifiedHeaders
|
||||||
|
|
||||||
|
|
||||||
class Transaction(BaseTransaction):
|
class Transaction(BaseTransaction):
|
||||||
|
@ -23,6 +23,7 @@ class MainNetLedger(BaseLedger):
|
||||||
symbol = 'BCH'
|
symbol = 'BCH'
|
||||||
network_name = 'mainnet'
|
network_name = 'mainnet'
|
||||||
|
|
||||||
|
headers_class = MainHeaders
|
||||||
transaction_class = Transaction
|
transaction_class = Transaction
|
||||||
|
|
||||||
pubkey_address_prefix = bytes((0,))
|
pubkey_address_prefix = bytes((0,))
|
||||||
|
@ -33,10 +34,6 @@ class MainNetLedger(BaseLedger):
|
||||||
default_fee_per_byte = 50
|
default_fee_per_byte = 50
|
||||||
|
|
||||||
|
|
||||||
class UnverifiedHeaders(BaseHeaders):
|
|
||||||
verify_bits_to_target = False
|
|
||||||
|
|
||||||
|
|
||||||
class RegTestLedger(MainNetLedger):
|
class RegTestLedger(MainNetLedger):
|
||||||
headers_class = UnverifiedHeaders
|
headers_class = UnverifiedHeaders
|
||||||
network_name = 'regtest'
|
network_name = 'regtest'
|
||||||
|
|
|
@ -7,6 +7,7 @@ __node_url__ = (
|
||||||
__electrumx__ = 'electrumx.lib.coins.BitcoinSegwitRegtest'
|
__electrumx__ = 'electrumx.lib.coins.BitcoinSegwitRegtest'
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
from typing import Optional
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from torba.baseledger import BaseLedger
|
from torba.baseledger import BaseLedger
|
||||||
from torba.baseheader import BaseHeaders, ArithUint256
|
from torba.baseheader import BaseHeaders, ArithUint256
|
||||||
|
@ -16,7 +17,7 @@ class MainHeaders(BaseHeaders):
|
||||||
header_size = 80
|
header_size = 80
|
||||||
chunk_size = 2016
|
chunk_size = 2016
|
||||||
max_target = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
max_target = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
genesis_hash = b'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
|
genesis_hash: Optional[bytes] = b'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'
|
||||||
target_timespan = 14 * 24 * 60 * 60
|
target_timespan = 14 * 24 * 60 * 60
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from binascii import unhexlify, hexlify
|
from binascii import unhexlify, hexlify
|
||||||
from typing import TypeVar, Sequence
|
from typing import TypeVar, Sequence, Optional
|
||||||
|
|
||||||
|
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
@ -52,7 +52,7 @@ class ArithUint256:
|
||||||
|
|
||||||
def __init__(self, value: int) -> None:
|
def __init__(self, value: int) -> None:
|
||||||
self._value = value
|
self._value = value
|
||||||
self._compact = None
|
self._compact: Optional[int] = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_compact(cls, compact) -> 'ArithUint256':
|
def from_compact(cls, compact) -> 'ArithUint256':
|
||||||
|
@ -80,10 +80,10 @@ class ArithUint256:
|
||||||
@property
|
@property
|
||||||
def bits(self) -> int:
|
def bits(self) -> int:
|
||||||
""" Returns the position of the highest bit set plus one. """
|
""" Returns the position of the highest bit set plus one. """
|
||||||
bn = bin(self._value)[2:]
|
bits = bin(self._value)[2:]
|
||||||
for i, d in enumerate(bn):
|
for i, d in enumerate(bits):
|
||||||
if d:
|
if d:
|
||||||
return (len(bn) - i) + 1
|
return (len(bits) - i) + 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue