commit 113b90e5e3438c9460651af61ffd3d040844b064
parent a7017e16fe0b671767d9de2fc81539dc960a0750
Author: nolash <dev@holbrook.no>
Date: Tue, 13 Apr 2021 06:50:33 +0200
Rename price, limit args
Diffstat:
5 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/chainlib/eth/gas.py b/chainlib/eth/gas.py
@@ -65,17 +65,19 @@ class RPCGasOracle:
def get_gas(self, code=None):
- o = price()
- r = self.conn.do(o)
- n = strip_0x(r)
+ gas_price = 0
+ if self.conn != None:
+ o = price()
+ r = self.conn.do(o)
+ n = strip_0x(r)
+ gas_price = int(n, 16)
fee_units = MINIMUM_FEE_UNITS
if self.code_callback != None:
fee_units = self.code_callback(code)
- price = int(n, 16)
- if price < self.min_price:
- logg.debug('adjusting price {} to set minimum {}'.format(price, self.min_price))
- price = self.min_price
- return (price, fee_units)
+ if gas_price < self.min_price:
+ logg.debug('adjusting price {} to set minimum {}'.format(gas_price, self.min_price))
+ gas_price = self.min_price
+ return (gas_price, fee_units)
class RPCPureGasOracle(RPCGasOracle):
@@ -93,9 +95,11 @@ class OverrideGasOracle(RPCGasOracle):
self.price = price
if self.limit == None or self.price == None:
- if conn != None:
- logg.debug('override gas oracle with rpc fallback')
- super(OverrideGasOracle, self).__init__(conn, code_callback)
+ price_conn = None
+ if self.price == None:
+ price_conn = conn
+ logg.debug('override gas oracle with rpc fallback; price {} limit {}'.format(self.price, self.limit))
+ super(OverrideGasOracle, self).__init__(price_conn, code_callback)
def get_gas(self, code=None):
@@ -103,9 +107,7 @@ class OverrideGasOracle(RPCGasOracle):
fee_units = None
fee_price = None
- rpc_results = None
- if self.conn != None:
- rpc_results = super(OverrideGasOracle, self).get_gas(code)
+ rpc_results = super(OverrideGasOracle, self).get_gas(code)
if self.limit != None:
fee_units = self.limit
@@ -122,10 +124,10 @@ class OverrideGasOracle(RPCGasOracle):
if fee_units == None:
if rpc_results != None:
fee_units = rpc_results[1]
- logg.debug('override gas oracle without explicit limit, setting from rpc {}'.format(fee_limit))
+ logg.debug('override gas oracle without explicit limit, setting from rpc {}'.format(fee_units))
else:
fee_units = MINIMUM_FEE_UNITS
- logg.debug('override gas oracle without explicit limit, setting default {}'.format(fee_limit))
+ logg.debug('override gas oracle without explicit limit, setting default {}'.format(fee_units))
return (fee_price, fee_units)
diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py
@@ -57,8 +57,8 @@ argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:et
argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing')
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
argparser.add_argument('--nonce', type=int, help='override nonce')
-argparser.add_argument('--price', type=int, help='override gas price')
-argparser.add_argument('--limit', type=int, help='override gas limit')
+argparser.add_argument('--gas-price', dest='gas_price', type=int, help='override gas price')
+argparser.add_argument('--gas-limit', dest='gas_limit', type=int, help='override gas limit')
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
@@ -101,8 +101,8 @@ else:
nonce_oracle = RPCNonceOracle(signer_address, conn)
gas_oracle = None
-if args.price or args.limit != None:
- gas_oracle = OverrideGasOracle(price=args.price, limit=args.limit, conn=conn)
+if args.gas_price or args.gas_limit != None:
+ gas_oracle = OverrideGasOracle(price=args.gas_price, limit=args.gas_limit, conn=conn)
else:
gas_oracle = RPCGasOracle(conn)
diff --git a/chainlib/eth/runnable/transfer.py b/chainlib/eth/runnable/transfer.py
@@ -58,8 +58,8 @@ argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFI
argparser.add_argument('-u', '--unsafe', dest='u', action='store_true', help='Auto-convert address to checksum adddress')
argparser.add_argument('-s', '--send', dest='s', action='store_true', help='Send to network')
argparser.add_argument('--nonce', type=int, help='Override nonce')
-argparser.add_argument('--price', type=int, help='Override gas price')
-argparser.add_argument('--limit', type=int, help='Override gas limit')
+argparser.add_argument('--gas-price', dest='gas_price', type=int, help='Override gas price')
+argparser.add_argument('--gas-limit', dest='gas_limit', type=int, help='Override gas limit')
argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more verbose')
argparser.add_argument('recipient', type=str, help='Recipient account address')
@@ -105,7 +105,7 @@ def _max_gas(code=None):
gas_oracle = None
if args.price != None:
- gas_oracle = OverrideGasOracle(args.price, args.limit)
+ gas_oracle = OverrideGasOracle(price=args.gas_price, limit=args.gas_limit)
else:
gas_oracle = RPCGasOracle(conn, code_callback=_max_gas)
diff --git a/chainlib/eth/tx.py b/chainlib/eth/tx.py
@@ -416,7 +416,7 @@ input {}
self.gas_used,
)
- s += 'status ' + self.status.name
+ s += 'status ' + self.status.name + '\n'
if self.contract != None:
s += """contract {}
diff --git a/setup.cfg b/setup.cfg
@@ -1,16 +1,15 @@
[metadata]
name = chainlib
-version = 0.0.2a7
+version = 0.0.2a8
description = Generic blockchain access library and tooling
author = Louis Holbrook
author_email = dev@holbrook.no
url = https://gitlab.com/nolash/chainlib
keywords =
- cic
+ dlt
+ blockchain
cryptocurrency
ethereum
- solidarity
- mutual_credit
classifiers =
Programming Language :: Python :: 3
Operating System :: OS Independent