Skip to content

Commit

Permalink
continue to move files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 13, 2025
1 parent 34b2465 commit fc7d0d1
Show file tree
Hide file tree
Showing 32 changed files with 71 additions and 96 deletions.
7 changes: 3 additions & 4 deletions counterparty-core/counterpartycore/lib/api/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
backend,
composer,
config,
deserialize,
exceptions,
gettxinfo,
ledger,
message_type,
script,
Expand All @@ -49,12 +47,13 @@
sweep, # noqa: F401
)
from counterpartycore.lib.messages.versions import enhanced_send # noqa: E402
from counterpartycore.lib.telemetry.util import ( # noqa: E402
from counterpartycore.lib.parser import deserialize, gettxinfo
from counterpartycore.lib.tools import sentry
from counterpartycore.lib.tools.telemetry.util import ( # noqa: E402
get_uptime,
is_docker,
is_force_enabled,
)
from counterpartycore.lib.tools import sentry
from flask import request
from flask_httpauth import HTTPBasicAuth
from jsonrpc import dispatcher
Expand Down
3 changes: 1 addition & 2 deletions counterparty-core/counterpartycore/lib/api/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
backend,
composer,
config,
deserialize,
exceptions,
gas,
gettxinfo,
message_type,
messages,
util,
)
from counterpartycore.lib.messages.attach import ID as UTXO_ID
from counterpartycore.lib.parser import deserialize, gettxinfo

D = decimal.Decimal

Expand Down
3 changes: 2 additions & 1 deletion counterparty-core/counterpartycore/lib/backend/bitcoind.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import requests
from requests.exceptions import ChunkedEncodingError, ConnectionError, ReadTimeout, Timeout

from counterpartycore.lib import config, deserialize, exceptions, script, util
from counterpartycore.lib import config, exceptions, script, util
from counterpartycore.lib.parser import deserialize
from counterpartycore.lib.util import ib2h

logger = logging.getLogger(config.LOGGER_NAME)
Expand Down
2 changes: 1 addition & 1 deletion counterparty-core/counterpartycore/lib/composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from counterpartycore.lib import (
backend,
config,
deserialize,
exceptions,
ledger,
script,
util,
)
from counterpartycore.lib.parser import deserialize

MAX_INPUTS_SET = 100

Expand Down
14 changes: 11 additions & 3 deletions counterparty-core/counterpartycore/lib/messages/burn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#! /usr/bin/python3
import csv
import decimal
import logging
import os

D = decimal.Decimal
from fractions import Fraction # noqa: E402
Expand All @@ -13,6 +14,13 @@

ID = 60

MAINNET_BURNS = {}
CURR_DIR = os.path.dirname(os.path.realpath(__file__))
with open(CURR_DIR + "/data/mainnet_burns.csv", "r") as f:

Check warning

Code scanning / pylint

Using open without explicitly specifying an encoding. Warning

Using open without explicitly specifying an encoding.
mainnet_burns_reader = csv.DictReader(f)
for line in mainnet_burns_reader:
MAINNET_BURNS[line["tx_hash"]] = line


def initialise(db):
cursor = db.cursor()
Expand Down Expand Up @@ -90,7 +98,7 @@ def compose(db, source: str, quantity: int, overburn: bool = False, skip_validat
return (source, [(destination, quantity)], None)


def parse(db, tx, mainnet_burns, message=None):
def parse(db, tx, message=None):

Check warning

Code scanning / pylint

Too many statements (51/50). Warning

Too many statements (51/50).

Check warning

Code scanning / pylint

Unused argument 'message'. Warning

Unused argument 'message'.
burn_parse_cursor = db.cursor()

if util.is_test_network():
Expand Down Expand Up @@ -153,7 +161,7 @@ def parse(db, tx, mainnet_burns, message=None):
# Mainnet burns are hard‐coded.

try:
line = mainnet_burns[tx["tx_hash"]]
line = MAINNET_BURNS[tx["tx_hash"]]

Check warning

Code scanning / pylint

Redefining name 'line' from outer scope (line 24). Warning

Redefining name 'line' from outer scope (line 24).
except KeyError:
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
"""

import binascii
import csv # noqa: E402
import decimal
import logging # noqa: E402
import os
import logging
import struct
import sys
import time
Expand All @@ -19,7 +17,6 @@
check,
config,
database,
deserialize,
exceptions,
gas,
ledger,
Expand All @@ -28,9 +25,7 @@
util,
)
from counterpartycore.lib.backend import rsfetcher
from counterpartycore.lib.gettxinfo import get_tx_info # noqa: E402

from .messages import ( # noqa: E402
from counterpartycore.lib.messages import ( # noqa: E402
attach,
bet,
broadcast,
Expand All @@ -53,7 +48,9 @@
sweep,
utxo,
)
from .messages.versions import enhanced_send, mpma # noqa: E402
from counterpartycore.lib.messages.versions import enhanced_send, mpma # noqa: E402
from counterpartycore.lib.parser import deserialize
from counterpartycore.lib.parser.gettxinfo import get_tx_info # noqa: E402

D = decimal.Decimal
logger = logging.getLogger(config.LOGGER_NAME)
Expand Down Expand Up @@ -95,13 +92,6 @@
"transaction_count",
]

MAINNET_BURNS = {}
CURR_DIR = os.path.dirname(os.path.realpath(__file__))
with open(CURR_DIR + "/../mainnet_burns.csv", "r") as f:
mainnet_burns_reader = csv.DictReader(f)
for line in mainnet_burns_reader:
MAINNET_BURNS[line["tx_hash"]] = line


def update_transaction(db, tx, supported):
ledger.add_to_journal(
Expand Down Expand Up @@ -167,7 +157,7 @@ def parse_tx(db, tx):

# Burns.
if tx["destination"] == config.UNSPENDABLE:
burn.parse(db, tx, MAINNET_BURNS)
burn.parse(db, tx)
return

# Protocol change.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from counterparty_rs import indexer

from counterpartycore.lib import config, util


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@

import zmq
import zmq.asyncio
from sentry_sdk import capture_exception

from counterpartycore.lib import (
backend,
blocks,
check,
config,
deserialize,
exceptions,
ledger,
mempool,
util,
)
from counterpartycore.lib.telemetry.oneshot import TelemetryOneShot
from counterpartycore.lib.parser import blocks, deserialize, mempool
from counterpartycore.lib.tools import sentry
from counterpartycore.lib.tools.telemetry.oneshot import TelemetryOneShot
from sentry_sdk import capture_exception

logger = logging.getLogger(config.LOGGER_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import struct
from io import BytesIO

from counterpartycore.lib import backend, config, ledger, message_type, p2sh, script, util
from counterpartycore.lib import backend, config, ledger, message_type, script, util
from counterpartycore.lib.exceptions import BTCOnlyError, DecodeError
from counterpartycore.lib.messages import dispenser
from counterpartycore.lib.opcodes import * # noqa: F403
from counterpartycore.lib.parser import p2sh
from counterpartycore.lib.util import inverse_hash

logger = logging.getLogger(config.LOGGER_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import logging
import time

from counterpartycore.lib import backend, blocks, config, deserialize, exceptions, ledger, util
from counterpartycore.lib import backend, config, exceptions, ledger, util
from counterpartycore.lib.api.api_watcher import EVENTS_ADDRESS_FIELDS
from counterpartycore.lib.parser import blocks, deserialize

logger = logging.getLogger(config.LOGGER_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import struct

import bitcoin as bitcoinlib

from counterpartycore.lib import config, exceptions, script

logger = logging.getLogger(config.LOGGER_NAME)
Expand Down
2 changes: 1 addition & 1 deletion counterparty-core/counterpartycore/lib/tools/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import sentry_sdk
from counterpartycore.lib import config, database
from counterpartycore.lib.telemetry.collectors.base import TelemetryCollectorBase
from counterpartycore.lib.tools.telemetry.collectors.base import TelemetryCollectorBase

logger = logging.getLogger(config.LOGGER_NAME)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import influxdb_client
from counterpartycore.lib import config
from counterpartycore.lib.telemetry.util import ID
from counterpartycore.lib.tools.telemetry.util import ID
from influxdb_client.client.write_api import SYNCHRONOUS

from .interface import TelemetryClientI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import os

import counterpartycore.lib.telemetry.util as util
from counterpartycore.lib import config, ledger # noqa: I001, F4
import counterpartycore.lib.tools.telemetry.util as util

Check warning

Code scanning / pylint

Use 'from counterpartycore.lib.tools.telemetry import util' instead. Warning

Use 'from counterpartycore.lib.tools.telemetry import util' instead.
from counterpartycore.lib import config, ledger

from .interface import TelemetryCollectorI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from counterpartycore.lib import config, blocks, ledger # noqa: I001, F401


class TelemetryCollectorI:
def collect(self):
raise NotImplementedError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging


from counterpartycore.lib.telemetry.collectors.interface import TelemetryCollectorI
from counterpartycore.lib.telemetry.clients.interface import TelemetryClientI
from counterpartycore.lib.tools.telemetry.collectors.interface import TelemetryCollectorI
from counterpartycore.lib.tools.telemetry.clients.interface import TelemetryClientI


from counterpartycore.lib import config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from counterpartycore.lib import config
from counterpartycore.lib.database import LedgerDBConnectionPool
from counterpartycore.lib.telemetry.clients.influxdb import TelemetryClientInfluxDB
from counterpartycore.lib.telemetry.collectors.influxdb import (
from counterpartycore.lib.tools.telemetry.clients.influxdb import TelemetryClientInfluxDB
from counterpartycore.lib.tools.telemetry.collectors.influxdb import (
TelemetryCollectorInfluxDB,
)
from counterpartycore.lib.util import SingletonMeta
Expand Down
3 changes: 1 addition & 2 deletions counterparty-core/counterpartycore/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@

from counterpartycore.lib import (
backend,
blocks,
bootstrap,
check,
config,
database,
exceptions,
follow,
ledger,
log,
util,
)
from counterpartycore.lib.api import api_server as api_v2
from counterpartycore.lib.api import api_v1, dbbuilder
from counterpartycore.lib.parser import blocks, follow

logger = logging.getLogger(config.LOGGER_NAME)
D = decimal.Decimal
Expand Down
8 changes: 2 additions & 6 deletions counterparty-core/counterpartycore/test/bytespersigop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@

import bitcoin as bitcoinlib

from counterpartycore.lib import api, blocks, composer, exceptions, ledger, util # noqa: F401
from counterpartycore.test import (
conftest, # noqa: F401
util_test,
)
from counterpartycore.lib import composer, util
from counterpartycore.test import util_test
from counterpartycore.test.fixtures.params import ADDR

# this is require near the top to do setup of the test suite
from counterpartycore.test.fixtures.params import DEFAULT_PARAMS as DP # noqa: F401
from counterpartycore.test.util_test import CURR_DIR

FIXTURE_SQL_FILE = CURR_DIR + "/fixtures/scenarios/unittest_fixture.sql"
Expand Down
3 changes: 2 additions & 1 deletion counterparty-core/counterpartycore/test/complex_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import pytest
from apsw import ConstraintError

from counterpartycore.lib import blocks, ledger, util
from counterpartycore.lib import ledger, util
from counterpartycore.lib.api import api_v1
from counterpartycore.lib.parser import blocks

# this is require near the top to do setup of the test suite
from counterpartycore.test import (
Expand Down
3 changes: 2 additions & 1 deletion counterparty-core/counterpartycore/test/deserialize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import bitcoin as bitcoinlib
import pytest

from counterpartycore.lib import config, deserialize, gettxinfo, util
from counterpartycore.lib import config, util
from counterpartycore.lib.parser import deserialize, gettxinfo
from counterpartycore.lib.util import inverse_hash


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ..params import DP

BLOCKS_VECTOR = {
"blocks": {
"parser.blocks": {
"parse_tx": [
{
"in": (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import binascii

from counterpartycore.lib import config, deserialize, exceptions
from counterpartycore.lib.gettxinfo import SighashFlagError
from counterpartycore.lib import config, exceptions
from counterpartycore.lib.parser import deserialize
from counterpartycore.lib.parser.gettxinfo import SighashFlagError

from ..params import DEFAULT_PARAMS as DP

config.NETWORK_NAME = "testnet"
config.PREFIX = b"TESTXXXX"

GETTXINFO_VECTOR = {
"gettxinfo": {
"parser.gettxinfo": {
"get_tx_info": [
# data in OP_CHECKSIG script
{
Expand Down
Loading

0 comments on commit fc7d0d1

Please sign in to comment.