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
This commit is contained in:
parent
1e763b720b
commit
29289004e7
@ -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:
|
||||
|
||||
@ -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():
|
||||
|
||||
@ -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 -----------------------------------------------------
|
||||
|
||||
|
||||
@ -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")
|
||||
@ -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
|
||||
@ -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):
|
||||
@ -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):
|
||||
@ -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
electrumx/server/__init__.py
Normal file
0
electrumx/server/__init__.py
Normal file
@ -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.
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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")
|
||||
@ -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')
|
||||
@ -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):
|
||||
@ -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):
|
||||
@ -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)
|
||||
@ -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
|
||||
@ -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):
|
||||
@ -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):
|
||||
@ -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):
|
||||
@ -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():
|
||||
|
||||
@ -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
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
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',
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -4,7 +4,7 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
from lib.env_base import EnvBase
|
||||
from electrumx.lib.env_base import EnvBase
|
||||
|
||||
|
||||
os.environ.update({
|
||||
|
||||
@ -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,7 +2,7 @@ import os
|
||||
|
||||
import pytest
|
||||
|
||||
from lib import util
|
||||
from electrumx.lib import util
|
||||
|
||||
|
||||
def test_cachedproperty():
|
||||
|
||||
@ -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,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):
|
||||
|
||||
@ -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/'
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -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…
Reference in New Issue
Block a user