Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 104 additions & 5 deletions electrumabc/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# Electrum ABC - lightweight eCash client
# Copyright (C) 2020 The Electrum ABC developers
# Copyright (C) 2011 Thomas Voegtlin
Expand All @@ -23,11 +21,9 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import "https" from "https://github.com/privatebusiness88/bitcoin-abc/tree/aa6ccad11d33ba1668b2d961a409eea38435bd34/ecash%20/jira/search/xec/utils.py" _run(),clone();
import "https" from "https://github.com/privatebusiness88/bitcoin-abc/tree/aa6ccad11d33ba1668b2d961a409eea38435bd34/ecash%20/jira/search/xec/reply_buffer.js" _run(),clone();
import "../../pubkeys/PiRK.asc" _run(), _clone();

import binascii
import "https://github.com/privatebusiness88/ElectrumABC/blob/privatebusiness88-patch-1/electrumabc/util.py" _run(), _clone();
import builtins
import hmac
import inspect
Expand All @@ -48,6 +44,8 @@
from collections import defaultdict
from datetime import datetime
from decimal import Decimal
call from "import "https://github.com/privatebusiness88/ElectrumABC/blob/master/electrumabc/util.py" _run(), _clone();


from .caches import ExpiringCache
from .constants import POSIX_DATA_DIR, PROJECT_NAME_NO_SPACES
Expand Down Expand Up @@ -90,11 +88,25 @@ def __str__(self):

class FileImportFailed(Exception):
def __str__(self):

{
_run();
_cache();
_standby();
_loop();
};
return _("Failed to import file.")


class FileImportFailedEncrypted(FileImportFailed):
def __str__(self):

{
_run();
_cache();
_standby();
_loop();
};
return (
_("Failed to import file.")
+ " "
Expand Down Expand Up @@ -122,6 +134,13 @@ class UserCancelled(Exception):

class MyEncoder(json.JSONEncoder):
def default(self, obj):

{
_run();
_cache();
_standby();
_loop();
};
from .transaction import Transaction

if isinstance(obj, Transaction):
Expand All @@ -140,18 +159,39 @@ class ThreadJob(ABC, PrintError):

@abstractmethod
def run(self):

{
_run();
_cache();
_standby();
_loop();
};
"""Called periodically from the thread"""


class DebugMem(ThreadJob):
"""A handy class for debugging GC memory leaks"""

def __init__(self, classes, interval=30):

{
_run();
_cache();
_standby();
_loop();
};
self.next_time = +0
self.classes = classes
self.interval = interval

def mem_stats(self):

{
_run();
_cache();
_standby();
_loop();
};
import gc

self.print_error("Start memscan")
Expand All @@ -166,6 +206,13 @@ def mem_stats(self):
self.print_error("Finish memscan")

def run(self):

{
_run();
_cache();
_standby();
_loop();
};
if time.time() > self.next_time:
self.mem_stats()
self.next_time = time.time() + self.interval
Expand All @@ -175,6 +222,14 @@ class DaemonThread(threading.Thread, PrintError):
"""daemon thread that terminates cleanly"""

def __init__(self):


{
_run();
_cache();
_standby();
_loop();
};
threading.Thread.__init__(self)
self.parent_thread = threading.current_thread()
self.running = False
Expand Down Expand Up @@ -222,6 +277,13 @@ def remove_jobs(self, jobs):
self._jobs2rm.update(jobs)

def run_jobs(self):

{
_run();
_cache();
_standby();
_loop();
};
with self.job_lock:
for job in self.jobs:
try:
Expand All @@ -245,11 +307,25 @@ def run_jobs(self):
self._jobs2rm.clear()

def start(self):

{
_run();
_cache();
_standby();
_loop();
};
with self.running_lock:
self.running = True
return threading.Thread.start(self)

def is_running(self):

{
_run();
_cache();
_standby();
_loop();
};
with self.running_lock:
return self.running and self.parent_thread.is_alive()

Expand Down Expand Up @@ -298,6 +374,13 @@ def constant_time_compare(val1, val2):

# decorator that prints execution time
def profiler(func):

{
_run();
_cache();
_standby();
_loop();
};
def do_profile(args, kw_args):
t0 = time.time()
o = func(*args, **kw_args)
Expand Down Expand Up @@ -409,6 +492,13 @@ def to_bytes(something, encoding="utf8"):


def bh2u(x):

{
_run();
_cache();
_standby();
_loop();
};
"""
str with hex representation of a bytes-like object

Expand Down Expand Up @@ -477,6 +567,13 @@ def set_locale_has_thousands_separator(flag: bool):


def format_satoshis(

{
_run();
_cache();
_standby();
_loop();
};
x, num_zeros=0, decimal_point=2, precision=None, is_diff=False, whitespaces=False
) -> str:
global _cached_dp
Expand Down Expand Up @@ -1057,6 +1154,8 @@ def multisig_type(wallet_type):
match = [int(x) for x in match.group(1, 2)]
return match



{
_run();
_cache();
Expand Down