Browse Source

electrumx package (#511)

* moved wallet, server, lib into electrumx main module

* fixed imports and other path references affected by electrumx main package

* fixing formatting to pass the pycodetest on travis
patch-2
Lex Berezhny 6 years ago
committed by Neil
parent
commit
29289004e7
  1. 4
      .travis.yml
  2. 4
      compact_history.py
  3. 2
      docs/conf.py
  4. 0
      electrumx/__init__.py
  5. 0
      electrumx/lib/__init__.py
  6. 15
      electrumx/lib/coins.py
  7. 0
      electrumx/lib/enum.py
  8. 0
      electrumx/lib/env_base.py
  9. 2
      electrumx/lib/hash.py
  10. 4
      electrumx/lib/peer.py
  11. 4
      electrumx/lib/script.py
  12. 0
      electrumx/lib/server_base.py
  13. 9
      electrumx/lib/tx.py
  14. 0
      electrumx/lib/util.py
  15. 0
      electrumx/server/__init__.py
  16. 10
      electrumx/server/block_processor.py
  17. 19
      electrumx/server/controller.py
  18. 4
      electrumx/server/daemon.py
  19. 8
      electrumx/server/db.py
  20. 6
      electrumx/server/env.py
  21. 4
      electrumx/server/history.py
  22. 6
      electrumx/server/mempool.py
  23. 4
      electrumx/server/peers.py
  24. 6
      electrumx/server/session.py
  25. 2
      electrumx/server/storage.py
  26. 0
      electrumx/server/version.py
  27. 6
      electrumx/wallet/bip32.py
  28. 2
      electrumx/wallet/env.py
  29. 2
      electrumx_rpc.py
  30. 4
      electrumx_server.py
  31. 6
      query.py
  32. 4
      setup.py
  33. 4
      tests/lib/test_addresses.py
  34. 2
      tests/lib/test_env_base.py
  35. 2
      tests/lib/test_hash.py
  36. 2
      tests/lib/test_util.py
  37. 4
      tests/server/test_api.py
  38. 6
      tests/server/test_compaction.py
  39. 4
      tests/server/test_env.py
  40. 4
      tests/server/test_storage.py
  41. 4
      tests/test_blocks.py
  42. 6
      tests/wallet/test_bip32.py

4
.travis.yml

@ -32,8 +32,8 @@ install:
- pip install git+https://github.com/goacoincore/neoscrypt
# command to run tests
script:
- pytest --cov=server --cov=lib --cov=wallet
- pycodestyle server/*.py lib/*.py
- pytest --cov=electrumx
- pycodestyle electrumx/server/*.py electrumx/lib/*.py
- sh -c "cd docs && make html"
# Dont report coverage from nightly
after_success:

4
compact_history.py

@ -36,8 +36,8 @@ import sys
import traceback
from os import environ
from server.env import Env
from server.db import DB
from electrumx.server.env import Env
from electrumx.server.db import DB
def compact_history():

2
docs/conf.py

@ -15,7 +15,7 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from server.version import VERSION
from electrumx.server.version import VERSION
# -- Project information -----------------------------------------------------

0
lib/__init__.py → electrumx/__init__.py

0
server/__init__.py → electrumx/lib/__init__.py

15
lib/coins.py → electrumx/lib/coins.py

@ -38,13 +38,14 @@ from hashlib import sha256
from functools import partial
import base64
import lib.util as util
from lib.hash import Base58, hash160, double_sha256, hash_to_str, HASHX_LEN
from lib.script import ScriptPubKey, OpCodes
import lib.tx as lib_tx
from server.block_processor import BlockProcessor
import server.daemon as daemon
from server.session import ElectrumX, DashElectrumX
import electrumx.lib.util as util
from electrumx.lib.hash import Base58, hash160, double_sha256, hash_to_str
from electrumx.lib.hash import HASHX_LEN
from electrumx.lib.script import ScriptPubKey, OpCodes
import electrumx.lib.tx as lib_tx
from electrumx.server.block_processor import BlockProcessor
import electrumx.server.daemon as daemon
from electrumx.server.session import ElectrumX, DashElectrumX
Block = namedtuple("Block", "raw header transactions")

0
lib/enum.py → electrumx/lib/enum.py

0
lib/env_base.py → electrumx/lib/env_base.py

2
lib/hash.py → electrumx/lib/hash.py

@ -29,7 +29,7 @@
import hashlib
import hmac
from lib.util import bytes_to_int, int_to_bytes, hex_to_bytes
from electrumx.lib.util import bytes_to_int, int_to_bytes, hex_to_bytes
_sha256 = hashlib.sha256
_sha512 = hashlib.sha512

4
lib/peer.py → electrumx/lib/peer.py

@ -27,8 +27,8 @@
from ipaddress import ip_address
from lib.util import cachedproperty
import lib.util as util
from electrumx.lib.util import cachedproperty
import electrumx.lib.util as util
class Peer(object):

4
lib/script.py → electrumx/lib/script.py

@ -30,8 +30,8 @@
import struct
from collections import namedtuple
from lib.enum import Enumeration
from lib.hash import hash160
from electrumx.lib.enum import Enumeration
from electrumx.lib.hash import hash160
class ScriptError(Exception):

0
lib/server_base.py → electrumx/lib/server_base.py

9
lib/tx.py → electrumx/lib/tx.py

@ -30,10 +30,11 @@
from collections import namedtuple
from lib.hash import double_sha256, hash_to_str
from lib.util import (cachedproperty, unpack_int32_from, unpack_int64_from,
unpack_uint16_from, unpack_uint32_from,
unpack_uint64_from)
from electrumx.lib.hash import double_sha256, hash_to_str
from electrumx.lib.util import (
cachedproperty, unpack_int32_from, unpack_int64_from,
unpack_uint16_from, unpack_uint32_from, unpack_uint64_from
)
class Tx(namedtuple("Tx", "version inputs outputs locktime")):

0
lib/util.py → electrumx/lib/util.py

0
electrumx/server/__init__.py

10
server/block_processor.py → electrumx/server/block_processor.py

@ -16,10 +16,10 @@ from struct import pack, unpack
import time
from functools import partial
from server.daemon import DaemonError
from lib.hash import hash_to_str, HASHX_LEN
from lib.util import chunks, formatted_time
import server.db
from electrumx.server.daemon import DaemonError
from electrumx.lib.hash import hash_to_str, HASHX_LEN
from electrumx.lib.util import chunks, formatted_time
import electrumx.server.db
class Prefetcher(object):
@ -132,7 +132,7 @@ class ChainError(Exception):
'''Raised on error processing blocks.'''
class BlockProcessor(server.db.DB):
class BlockProcessor(electrumx.server.db.DB):
'''Process blocks and update the DB state to match.
Employ a prefetcher to prefetch blocks in batches for processing.

19
server/controller.py → electrumx/server/controller.py

@ -20,15 +20,16 @@ from functools import partial
import pylru
from aiorpcx import RPCError, TaskSet, _version as aiorpcx_version
from lib.hash import double_sha256, hash_to_str, hex_str_to_hash, HASHX_LEN
from lib.peer import Peer
from lib.server_base import ServerBase
import lib.util as util
from server.daemon import DaemonError
from server.mempool import MemPool
from server.peers import PeerManager
from server.session import LocalRPC, BAD_REQUEST, DAEMON_ERROR
from server.version import VERSION
from electrumx.lib.hash import double_sha256, hash_to_str, hex_str_to_hash
from electrumx.lib.hash import HASHX_LEN
from electrumx.lib.peer import Peer
from electrumx.lib.server_base import ServerBase
import electrumx.lib.util as util
from electrumx.server.daemon import DaemonError
from electrumx.server.mempool import MemPool
from electrumx.server.peers import PeerManager
from electrumx.server.session import LocalRPC, BAD_REQUEST, DAEMON_ERROR
from electrumx.server.version import VERSION
version_string = util.version_string

4
server/daemon.py → electrumx/server/daemon.py

@ -18,8 +18,8 @@ from time import strptime
import aiohttp
from lib.util import int_to_varint, hex_to_bytes
from lib.hash import hex_str_to_hash
from electrumx.lib.util import int_to_varint, hex_to_bytes
from electrumx.lib.hash import hex_str_to_hash
from aiorpcx import JSONRPC

8
server/db.py → electrumx/server/db.py

@ -17,10 +17,10 @@ from struct import pack, unpack
from bisect import bisect_right
from collections import namedtuple
import lib.util as util
from lib.hash import hash_to_str, HASHX_LEN
from server.storage import db_class
from server.history import History
import electrumx.lib.util as util
from electrumx.lib.hash import hash_to_str, HASHX_LEN
from electrumx.server.storage import db_class
from electrumx.server.history import History
UTXO = namedtuple("UTXO", "tx_num tx_pos tx_hash height value")

6
server/env.py → electrumx/server/env.py

@ -13,9 +13,9 @@ import resource
from collections import namedtuple
from ipaddress import ip_address
from lib.coins import Coin
from lib.env_base import EnvBase
import lib.util as lib_util
from electrumx.lib.coins import Coin
from electrumx.lib.env_base import EnvBase
import electrumx.lib.util as lib_util
NetIdentity = namedtuple('NetIdentity', 'host tcp_port ssl_port nick_suffix')

4
server/history.py → electrumx/server/history.py

@ -16,8 +16,8 @@ from functools import partial
import logging
from struct import pack, unpack
import lib.util as util
from lib.hash import hash_to_str, HASHX_LEN
import electrumx.lib.util as util
from electrumx.lib.hash import hash_to_str, HASHX_LEN
class History(object):

6
server/mempool.py → electrumx/server/mempool.py

@ -13,9 +13,9 @@ import logging
import time
from collections import defaultdict
from lib.hash import hash_to_str, hex_str_to_hash
from server.daemon import DaemonError
from server.db import UTXO
from electrumx.lib.hash import hash_to_str, hex_str_to_hash
from electrumx.server.daemon import DaemonError
from electrumx.server.db import UTXO
class MemPool(object):

4
server/peers.py → electrumx/server/peers.py

@ -18,8 +18,8 @@ from functools import partial
from aiorpcx import ClientSession, RPCError, SOCKSProxy, ConnectionError
from lib.peer import Peer
from lib.util import ConnectionLogger
from electrumx.lib.peer import Peer
from electrumx.lib.util import ConnectionLogger
PEER_GOOD, PEER_STALE, PEER_NEVER, PEER_BAD = range(4)

6
server/session.py → electrumx/server/session.py

@ -15,9 +15,9 @@ from functools import partial
from aiorpcx import ServerSession, JSONRPCAutoDetect, RPCError
from lib.hash import sha256, hash_to_str
import lib.util as util
from server.daemon import DaemonError
from electrumx.lib.hash import sha256, hash_to_str
import electrumx.lib.util as util
from electrumx.server.daemon import DaemonError
BAD_REQUEST = 1
DAEMON_ERROR = 2

2
server/storage.py → electrumx/server/storage.py

@ -10,7 +10,7 @@
import os
from functools import partial
import lib.util as util
import electrumx.lib.util as util
def db_class(name):

0
server/version.py → electrumx/server/version.py

6
wallet/bip32.py → electrumx/wallet/bip32.py

@ -13,9 +13,9 @@ import ecdsa
import ecdsa.ellipticcurve as EC
import ecdsa.numbertheory as NT
from lib.coins import Coin
from lib.hash import Base58, hmac_sha512, hash160
from lib.util import cachedproperty, bytes_to_int, int_to_bytes
from electrumx.lib.coins import Coin
from electrumx.lib.hash import Base58, hmac_sha512, hash160
from electrumx.lib.util import cachedproperty, bytes_to_int, int_to_bytes
class DerivationError(Exception):

2
wallet/env.py → electrumx/wallet/env.py

@ -8,7 +8,7 @@
'''Class for handling environment configuration and defaults.'''
from lib.env_base import EnvBase
from electrumx.lib.env_base import EnvBase
class Env(EnvBase):

2
electrumx_rpc.py

@ -17,7 +17,7 @@ from os import environ
from aiorpcx import ClientSession
from server.controller import Controller
from electrumx.server.controller import Controller
def main():

4
electrumx_server.py

@ -12,8 +12,8 @@
import logging
import traceback
from server.env import Env
from server.controller import Controller
from electrumx.server.env import Env
from electrumx.server.controller import Controller
def main():

6
query.py

@ -15,9 +15,9 @@ Not currently documented; might become easier to use in future.
import sys
from server.env import Env
from server.db import DB
from lib.hash import hash_to_str
from electrumx.server.env import Env
from electrumx.server.db import DB
from electrumx.lib.hash import hash_to_str
def count_entries(hist_db, utxo_db):

4
setup.py

@ -1,5 +1,5 @@
import setuptools
from server.version import VERSION
from electrumx.server.version import VERSION
setuptools.setup(
@ -13,7 +13,7 @@ setuptools.setup(
# "blake256" package is required to sync Decred network.
# "xevan_hash" package is required to sync Xuez network.
install_requires=['aiorpcX >= 0.5.6', 'plyvel', 'pylru', 'aiohttp >= 1'],
packages=setuptools.find_packages(exclude=['tests']),
packages=setuptools.find_packages(include=('electrumx.*',)),
description='ElectrumX Server',
author='Neil Booth',
author_email='kyuupichan@gmail.com',

4
tests/lib/test_addresses.py

@ -26,8 +26,8 @@
import pytest
from lib.coins import Litecoin, BitcoinCash, Zcash, Emercoin, BitcoinGold
from lib.hash import Base58
from electrumx.lib.coins import Litecoin, BitcoinCash, Zcash, Emercoin, BitcoinGold
from electrumx.lib.hash import Base58
addresses = [
(BitcoinCash, "13xDKJbjh4acmLpNVr6Lc9hFcXRr9fyt4x",

2
tests/lib/test_env_base.py

@ -4,7 +4,7 @@ import os
import pytest
from lib.env_base import EnvBase
from electrumx.lib.env_base import EnvBase
os.environ.update({

2
tests/lib/test_hash.py

@ -5,7 +5,7 @@ from functools import partial
import pytest
import lib.hash as lib_hash
import electrumx.lib.hash as lib_hash
def test_sha256():

2
tests/lib/test_util.py

@ -2,7 +2,7 @@ import os
import pytest
from lib import util
from electrumx.lib import util
def test_cachedproperty():

4
tests/server/test_api.py

@ -2,8 +2,8 @@ import asyncio
from unittest import mock
from aiorpcx import RPCError
from server.env import Env
from server.controller import Controller
from electrumx.server.env import Env
from electrumx.server.controller import Controller
loop = asyncio.get_event_loop()

6
tests/server/test_compaction.py

@ -6,9 +6,9 @@ from os import environ, urandom
from struct import pack
import random
from lib.hash import hash_to_str, HASHX_LEN
from server.env import Env
from server.db import DB
from electrumx.lib.hash import hash_to_str, HASHX_LEN
from electrumx.server.env import Env
from electrumx.server.db import DB
def create_histories(history, hashX_count=100):

4
tests/server/test_env.py

@ -6,8 +6,8 @@ import re
import pytest
from server.env import Env, NetIdentity
import lib.coins as lib_coins
from electrumx.server.env import Env, NetIdentity
import electrumx.lib.coins as lib_coins
BASE_DAEMON_URL = 'http://username:password@hostname:321/'

4
tests/server/test_storage.py

@ -1,8 +1,8 @@
import pytest
import os
from server.storage import Storage, db_class
from lib.util import subclasses
from electrumx.server.storage import Storage, db_class
from electrumx.lib.util import subclasses
# Find out which db engines to test
# Those that are not installed will be skipped

4
tests/test_blocks.py

@ -30,8 +30,8 @@ from binascii import unhexlify
import pytest
from lib.coins import Coin
from lib.hash import hex_str_to_hash
from electrumx.lib.coins import Coin
from electrumx.lib.hash import hex_str_to_hash
BLOCKS_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'blocks')

6
tests/wallet/test_bip32.py

@ -4,9 +4,9 @@
import pytest
import wallet.bip32 as bip32
from lib.coins import BitcoinCash as Bitcoin, CoinError
from lib.hash import Base58
import electrumx.wallet.bip32 as bip32
from electrumx.lib.coins import BitcoinCash as Bitcoin, CoinError
from electrumx.lib.hash import Base58
MXPRV = 'xprv9s21ZrQH143K2gMVrSwwojnXigqHgm1khKZGTCm7K8w4PmuDEUrudk11ZBxhGPUiUeVcrfGLoZmt8rFNRDLp18jmKMcVma89z7PJd2Vn7R9'

Loading…
Cancel
Save