# Path: electrumx/lib/util.py
# class ConnectionLogger(logging.LoggerAdapter):
# class CompactFormatter(logging.Formatter):
# class cachedproperty(object):
# class LogicalFile(object):
#     def process(self, msg, kwargs):
#     def format(self, record):
# def make_logger(name, *, handler, level):
# def class_logger(path, classname):
#     def __init__(self, f):
#     def __get__(self, obj, type_):
# def formatted_time(t, sep=' '):
# def deep_getsizeof(obj):
#     def size(o):
# def subclasses(base_class, strict=True):
#     def select(obj):
# def chunks(items, size):
# def resolve_limit(limit):
# def bytes_to_int(be_bytes):
# def int_to_bytes(value):
# def increment_byte_string(bs):
#     def __init__(self, prefix, digits, file_size):
#     def read(self, start, size=-1):
#     def write(self, start, b):
#     def open_file(self, start, create):
# def open_file(filename, create=False):
# def open_truncate(filename):
# def address_string(address):
# def protocol_tuple(s):
# def version_string(ptuple):
# def protocol_version(client_req, min_tuple, max_tuple):
# def pack_varint(n):
# def pack_varbytes(data):


import os
        import plyvel
        import rocksdb
        import gc
from functools import partial
from electrumx.lib import util

    def write_batch(self):
        return RocksDBWriteBatch(self.db)

    def iterator(self, prefix=b'', reverse=False):
        return RocksDBIterator(self.db, prefix, reverse)


class RocksDBWriteBatch(object):
    '''A write batch for RocksDB.'''

    def __init__(self, db):
        self.batch = RocksDB.module.WriteBatch()
        self.db = db

    def __enter__(self):
        return self.batch

    def __exit__(self, exc_type, exc_val, exc_tb):
        if not exc_val:
            self.db.write(self.batch)


class RocksDBIterator(object):
    '''An iterator for RocksDB.'''

    def __init__(self, db, prefix, reverse):
        self.prefix = prefix
        if reverse:
            self.iterator = reversed(db.iteritems())

# Path: electrumx/lib/util.py
# class ConnectionLogger(logging.LoggerAdapter):
# class CompactFormatter(logging.Formatter):
# class cachedproperty(object):
# class LogicalFile(object):
#     def process(self, msg, kwargs):
#     def format(self, record):
# def make_logger(name, *, handler, level):
# def class_logger(path, classname):
#     def __init__(self, f):
#     def __get__(self, obj, type_):
# def formatted_time(t, sep=' '):
# def deep_getsizeof(obj):
#     def size(o):
# def subclasses(base_class, strict=True):
#     def select(obj):
# def chunks(items, size):
# def resolve_limit(limit):
# def bytes_to_int(be_bytes):
# def int_to_bytes(value):
# def increment_byte_string(bs):
#     def __init__(self, prefix, digits, file_size):
#     def read(self, start, size=-1):
#     def write(self, start, b):
#     def open_file(self, start, create):
# def open_file(filename, create=False):
# def open_truncate(filename):
# def address_string(address):
# def protocol_tuple(s):
# def version_string(ptuple):
# def protocol_version(client_req, min_tuple, max_tuple):
# def pack_varint(n):
# def pack_varbytes(data):


# Path: electrumx/server/storage.py
import os
        import plyvel
        import rocksdb
        import gc
from functools import partial
from electrumx.lib import util


    def write_batch(self):
        return RocksDBWriteBatch(self.db)

    def iterator(self, prefix=b'', reverse=False):
        return RocksDBIterator(self.db, prefix, reverse)


class RocksDBWriteBatch(object):
    '''A write batch for RocksDB.'''

    def __init__(self, db):
        self.batch = RocksDB.module.WriteBatch()
        self.db = db

    def __enter__(self):
        return self.batch

    def __exit__(self, exc_type, exc_val, exc_tb):
        if not exc_val:
            self.db.write(self.batch)


class RocksDBIterator(object):
    '''An iterator for RocksDB.'''

    def __init__(self, db, prefix, reverse):
        self.prefix = prefix
        if reverse:
            self.iterator = reversed(db.iteritems())

            nxt_prefix = util.increment_byte_string(prefix)