From 998a4c69b185d183d898bf83045c0e5285e2daf1 Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Sun, 12 Dec 2021 14:47:23 +0700 Subject: [PATCH] Introduce WRITE_TRANSACTION_COST_IN_DB environment variable to turn on or off this feature in neon-proxy --- proxy/common_neon/costs.py | 5 ++++- proxy/environment.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/proxy/common_neon/costs.py b/proxy/common_neon/costs.py index 9d42d6c84..86e58dd7e 100644 --- a/proxy/common_neon/costs.py +++ b/proxy/common_neon/costs.py @@ -1,7 +1,7 @@ import base58 import psycopg2 -from ..environment import EVM_LOADER_ID +from ..environment import EVM_LOADER_ID, WRITE_TRANSACTION_COST_IN_DB from ..indexer.sql_dict import POSTGRES_USER, POSTGRES_HOST, POSTGRES_DB, POSTGRES_PASSWORD class SQLCost(): @@ -47,6 +47,9 @@ def insert(self, hash, cost, used_gas, sender, to_address, sig, status, reason): def update_transaction_cost(receipt, eth_trx, extra_sol_trx=False, reason=None): + if not WRITE_TRANSACTION_COST_IN_DB: + return + cost = receipt['result']['meta']['preBalances'][0] - receipt['result']['meta']['postBalances'][0] if eth_trx: hash = eth_trx.hash_signed().hex() diff --git a/proxy/environment.py b/proxy/environment.py index dc1c7d55f..3ac27f98a 100644 --- a/proxy/environment.py +++ b/proxy/environment.py @@ -18,6 +18,7 @@ EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "0")) LOG_SENDING_SOLANA_TRANSACTION = os.environ.get("LOG_SENDING_SOLANA_TRANSACTION", "NO") == "YES" LOG_NEON_CLI_DEBUG = os.environ.get("LOG_NEON_CLI_DEBUG", "NO") == "YES" +WRITE_TRANSACTION_COST_IN_DB = os.environ.get("WRITE_TRANSACTION_COST_IN_DB", "NO") == "YES" class solana_cli: def call(self, *args):