Skip to content

Commit

Permalink
misc s8 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Oct 11, 2024
1 parent 1e8c288 commit 21fb322
Show file tree
Hide file tree
Showing 72 changed files with 4,454 additions and 3,524 deletions.
32 changes: 15 additions & 17 deletions code/kmd_ntx_api/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from kmd_ntx_api.logger import logger
from kmd_ntx_api.helper import get_or_none, sort_dict
from kmd_ntx_api.cache_data import coins_config_cache, refresh_cache, ACTIVATION_COMMANDS_PATH
from kmd_ntx_api.cache_data import cached


def get_zhtlc_activation(coins_config, coin):
Expand Down Expand Up @@ -168,23 +168,21 @@ def get_activation_command(coins_config: Dict[str, Dict[str, Any]], coin: str) -


def get_activation_commands(request):
logger.info("=========================================== Running get_activation_commands ===================================")
enable_commands = {"commands":{}}
resp_json = {}

coins_config = coins_config_cache()
selected_coin = get_or_none(request, "coin")
if selected_coin is None:
for coin in coins_config:
if coin.startswith('I') or coin.startswith('G'):
logger.calc(coin)

platform, resp_json = get_activation_command(coins_config, coin)
if platform not in enable_commands["commands"]:
enable_commands["commands"].update({platform: {}})
enable_commands["commands"][platform].update({coin: sort_dict(resp_json)})
# Update memcache
refresh_cache(path=ACTIVATION_COMMANDS_PATH, data=enable_commands, force=False, key="activation_commands_cache", expire=86400)
resp_json = {}
enable_commands = cached.get_data("activation_commands_cache")
if enable_commands is None:
logger.info("================ Running get_activation_commands ================")
enable_commands = {}
coins_config = cached.get_data("coins_config_cache")
for coin in coins_config:
platform, resp_json = get_activation_command(coins_config, coin)
if platform not in enable_commands:
enable_commands.update({platform: {}})
enable_commands[platform].update({coin: sort_dict(resp_json)})
# Update memcache
cached.refresh(data=enable_commands, force=False, key="activation_commands_cache", expire=86400)
return enable_commands
else:
platform, resp_json = get_activation_command(coins_config, selected_coin)
Expand All @@ -194,7 +192,7 @@ def get_activation_commands(request):
def get_coin_activation_commands(request):
coin_commands = {}
logger.info("Running get_coin_activation_commands")
protocol_commands = get_activation_commands(request)["commands"]
protocol_commands = get_activation_commands(request)
for protocol in protocol_commands:
for coin in protocol_commands[protocol]:
coin_commands.update({coin: protocol_commands[protocol][coin]})
Expand Down
4 changes: 2 additions & 2 deletions code/kmd_ntx_api/atomicdex_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
from django.contrib import messages
from django.shortcuts import render
from kmd_ntx_api.cache_data import activation_commands_cache
from kmd_ntx_api.cache_data import cached
from kmd_ntx_api.helper import get_or_none
from kmd_ntx_api.context import get_base_context
from kmd_ntx_api.forms import EnableCommandForm, MakerbotForm
Expand All @@ -20,7 +20,7 @@ def activation_commands_view(request):

def batch_activation_form_view(request):
context = get_base_context(request)
activation_commands = activation_commands_cache()
activation_commands = cached.get_data("activation_commands_cache")
context.update({
"page_title":"Generate AtomicDEX-API Batch Activation Commands",
"mm2_coins": True
Expand Down
4 changes: 2 additions & 2 deletions code/kmd_ntx_api/based_58.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from kmd_ntx_api.const import OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG
from kmd_ntx_api.const import EXCLUDE_DECODE_OPRET_COINS, noMoM, SMARTCHAINS
from kmd_ntx_api.info import get_all_coins
from kmd_ntx_api.cache_data import b58_params_cache
from kmd_ntx_api.cache_data import cached
from kmd_ntx_api.helper import has_error
from kmd_ntx_api.logger import logger

Expand Down Expand Up @@ -291,7 +291,7 @@ def convert_addresses(address):
"errors": []
}

base58_coins = b58_params_cache()
base58_coins = cached.get_data("b58_params_cache")

for coin in base58_coins:
decoded_bytes = bitcoin.base58.decode(address)
Expand Down
Loading

0 comments on commit 21fb322

Please sign in to comment.