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
|
- 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:
|
||||||
|
|||||||
@ -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():
|
||||||
|
|||||||
@ -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 -----------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -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")
|
||||||
@ -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
|
||||||
@ -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):
|
||||||
@ -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):
|
||||||
@ -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
electrumx/server/__init__.py
Normal file
0
electrumx/server/__init__.py
Normal file
@ -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.
|
||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
||||||
|
|
||||||
|
|
||||||
@ -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")
|
||||||
@ -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')
|
||||||
@ -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):
|
||||||
@ -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):
|
||||||
@ -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)
|
||||||
@ -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
|
||||||
@ -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):
|
||||||
@ -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):
|
||||||
@ -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):
|
||||||
@ -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():
|
||||||
|
|||||||
@ -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
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
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',
|
||||||
|
|||||||
@ -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",
|
||||||
|
|||||||
@ -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({
|
||||||
|
|||||||
@ -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,7 +2,7 @@ import os
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from lib import util
|
from electrumx.lib import util
|
||||||
|
|
||||||
|
|
||||||
def test_cachedproperty():
|
def test_cachedproperty():
|
||||||
|
|||||||
@ -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,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):
|
||||||
|
|||||||
@ -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/'
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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')
|
||||||
|
|||||||
@ -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…
Reference in New Issue
Block a user