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 - pip install git+https://github.com/goacoincore/neoscrypt
# command to run tests # command to run tests
script: script:
- pytest --cov=server --cov=lib --cov=wallet - pytest --cov=electrumx
- pycodestyle server/*.py lib/*.py - pycodestyle electrumx/server/*.py electrumx/lib/*.py
- sh -c "cd docs && make html" - sh -c "cd docs && make html"
# Dont report coverage from nightly # Dont report coverage from nightly
after_success: after_success:

4
compact_history.py

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

2
docs/conf.py

@ -15,7 +15,7 @@
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('..')) sys.path.insert(0, os.path.abspath('..'))
from server.version import VERSION from electrumx.server.version import VERSION
# -- Project information ----------------------------------------------------- # -- 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 from functools import partial
import base64 import base64
import lib.util as util import electrumx.lib.util as util
from lib.hash import Base58, hash160, double_sha256, hash_to_str, HASHX_LEN from electrumx.lib.hash import Base58, hash160, double_sha256, hash_to_str
from lib.script import ScriptPubKey, OpCodes from electrumx.lib.hash import HASHX_LEN
import lib.tx as lib_tx from electrumx.lib.script import ScriptPubKey, OpCodes
from server.block_processor import BlockProcessor import electrumx.lib.tx as lib_tx
import server.daemon as daemon from electrumx.server.block_processor import BlockProcessor
from server.session import ElectrumX, DashElectrumX import electrumx.server.daemon as daemon
from electrumx.server.session import ElectrumX, DashElectrumX
Block = namedtuple("Block", "raw header transactions") 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 hashlib
import hmac 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 _sha256 = hashlib.sha256
_sha512 = hashlib.sha512 _sha512 = hashlib.sha512

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

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

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

@ -30,8 +30,8 @@
import struct import struct
from collections import namedtuple from collections import namedtuple
from lib.enum import Enumeration from electrumx.lib.enum import Enumeration
from lib.hash import hash160 from electrumx.lib.hash import hash160
class ScriptError(Exception): 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 collections import namedtuple
from lib.hash import double_sha256, hash_to_str from electrumx.lib.hash import double_sha256, hash_to_str
from lib.util import (cachedproperty, unpack_int32_from, unpack_int64_from, from electrumx.lib.util import (
unpack_uint16_from, unpack_uint32_from, cachedproperty, unpack_int32_from, unpack_int64_from,
unpack_uint64_from) unpack_uint16_from, unpack_uint32_from, unpack_uint64_from
)
class Tx(namedtuple("Tx", "version inputs outputs locktime")): 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 import time
from functools import partial from functools import partial
from server.daemon import DaemonError from electrumx.server.daemon import DaemonError
from lib.hash import hash_to_str, HASHX_LEN from electrumx.lib.hash import hash_to_str, HASHX_LEN
from lib.util import chunks, formatted_time from electrumx.lib.util import chunks, formatted_time
import server.db import electrumx.server.db
class Prefetcher(object): class Prefetcher(object):
@ -132,7 +132,7 @@ class ChainError(Exception):
'''Raised on error processing blocks.''' '''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. '''Process blocks and update the DB state to match.
Employ a prefetcher to prefetch blocks in batches for processing. 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 import pylru
from aiorpcx import RPCError, TaskSet, _version as aiorpcx_version 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 electrumx.lib.hash import double_sha256, hash_to_str, hex_str_to_hash
from lib.peer import Peer from electrumx.lib.hash import HASHX_LEN
from lib.server_base import ServerBase from electrumx.lib.peer import Peer
import lib.util as util from electrumx.lib.server_base import ServerBase
from server.daemon import DaemonError import electrumx.lib.util as util
from server.mempool import MemPool from electrumx.server.daemon import DaemonError
from server.peers import PeerManager from electrumx.server.mempool import MemPool
from server.session import LocalRPC, BAD_REQUEST, DAEMON_ERROR from electrumx.server.peers import PeerManager
from server.version import VERSION from electrumx.server.session import LocalRPC, BAD_REQUEST, DAEMON_ERROR
from electrumx.server.version import VERSION
version_string = util.version_string version_string = util.version_string

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

@ -18,8 +18,8 @@ from time import strptime
import aiohttp import aiohttp
from lib.util import int_to_varint, hex_to_bytes from electrumx.lib.util import int_to_varint, hex_to_bytes
from lib.hash import hex_str_to_hash from electrumx.lib.hash import hex_str_to_hash
from aiorpcx import JSONRPC 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 bisect import bisect_right
from collections import namedtuple from collections import namedtuple
import lib.util as util import electrumx.lib.util as util
from lib.hash import hash_to_str, HASHX_LEN from electrumx.lib.hash import hash_to_str, HASHX_LEN
from server.storage import db_class from electrumx.server.storage import db_class
from server.history import History from electrumx.server.history import History
UTXO = namedtuple("UTXO", "tx_num tx_pos tx_hash height value") 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 collections import namedtuple
from ipaddress import ip_address from ipaddress import ip_address
from lib.coins import Coin from electrumx.lib.coins import Coin
from lib.env_base import EnvBase from electrumx.lib.env_base import EnvBase
import lib.util as lib_util import electrumx.lib.util as lib_util
NetIdentity = namedtuple('NetIdentity', 'host tcp_port ssl_port nick_suffix') 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 import logging
from struct import pack, unpack from struct import pack, unpack
import lib.util as util import electrumx.lib.util as util
from lib.hash import hash_to_str, HASHX_LEN from electrumx.lib.hash import hash_to_str, HASHX_LEN
class History(object): class History(object):

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

@ -13,9 +13,9 @@ import logging
import time import time
from collections import defaultdict from collections import defaultdict
from lib.hash import hash_to_str, hex_str_to_hash from electrumx.lib.hash import hash_to_str, hex_str_to_hash
from server.daemon import DaemonError from electrumx.server.daemon import DaemonError
from server.db import UTXO from electrumx.server.db import UTXO
class MemPool(object): 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 aiorpcx import ClientSession, RPCError, SOCKSProxy, ConnectionError
from lib.peer import Peer from electrumx.lib.peer import Peer
from lib.util import ConnectionLogger from electrumx.lib.util import ConnectionLogger
PEER_GOOD, PEER_STALE, PEER_NEVER, PEER_BAD = range(4) 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 aiorpcx import ServerSession, JSONRPCAutoDetect, RPCError
from lib.hash import sha256, hash_to_str from electrumx.lib.hash import sha256, hash_to_str
import lib.util as util import electrumx.lib.util as util
from server.daemon import DaemonError from electrumx.server.daemon import DaemonError
BAD_REQUEST = 1 BAD_REQUEST = 1
DAEMON_ERROR = 2 DAEMON_ERROR = 2

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

@ -10,7 +10,7 @@
import os import os
from functools import partial from functools import partial
import lib.util as util import electrumx.lib.util as util
def db_class(name): 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.ellipticcurve as EC
import ecdsa.numbertheory as NT import ecdsa.numbertheory as NT
from lib.coins import Coin from electrumx.lib.coins import Coin
from lib.hash import Base58, hmac_sha512, hash160 from electrumx.lib.hash import Base58, hmac_sha512, hash160
from lib.util import cachedproperty, bytes_to_int, int_to_bytes from electrumx.lib.util import cachedproperty, bytes_to_int, int_to_bytes
class DerivationError(Exception): class DerivationError(Exception):

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

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

2
electrumx_rpc.py

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

4
electrumx_server.py

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

6
query.py

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

4
setup.py

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

4
tests/lib/test_addresses.py

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

2
tests/lib/test_env_base.py

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

2
tests/lib/test_hash.py

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

2
tests/lib/test_util.py

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

4
tests/server/test_api.py

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

6
tests/server/test_compaction.py

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

4
tests/server/test_env.py

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

4
tests/server/test_storage.py

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

4
tests/test_blocks.py

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

6
tests/wallet/test_bip32.py

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

Loading…
Cancel
Save