-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v10.10.0] Code cleaning #2937
[v10.10.0] Code cleaning #2937
Conversation
@@ -13,6 +14,13 @@ | |||
|
|||
ID = 60 | |||
|
|||
MAINNET_BURNS = {} | |||
CURR_DIR = os.path.dirname(os.path.realpath(__file__)) | |||
with open(CURR_DIR + "/data/mainnet_burns.csv", "r") as f: |
Check warning
Code scanning / pylint
Using open without explicitly specifying an encoding. Warning
counterparty-core/counterpartycore/lib/tools/telemetry/collectors/base.py
Fixed
Show fixed
Hide fixed
# N-of-2 | ||
if len(asm) == 5 and asm[3] == 2 and asm[4] == OP_CHECKMULTISIG: # noqa: F405 | ||
pubkeys, signatures_required = asm[1:3], asm[0] | ||
if all([type(pubkey) == bytes for pubkey in pubkeys]): # noqa: E721 |
Check warning
Code scanning / pylint
Use isinstance() rather than type() for a typecheck. Warning
# N-of-3 | ||
if len(asm) == 6 and asm[4] == 3 and asm[5] == OP_CHECKMULTISIG: # noqa: F405 | ||
pubkeys, signatures_required = asm[1:4], asm[0] | ||
if all([type(pubkey) == bytes for pubkey in pubkeys]): # noqa: E721 |
Check warning
Code scanning / pylint
Use a generator instead 'all(type(pubkey) == bytes for pubkey in pubkeys)'. Warning
# N-of-3 | ||
if len(asm) == 6 and asm[4] == 3 and asm[5] == OP_CHECKMULTISIG: # noqa: F405 | ||
pubkeys, signatures_required = asm[1:4], asm[0] | ||
if all([type(pubkey) == bytes for pubkey in pubkeys]): # noqa: E721 |
Check warning
Code scanning / pylint
Use isinstance() rather than type() for a typecheck. Warning
# Sum data chunks to get data. (Can mix OP_RETURN and multi-sig.) | ||
asm = script.script_to_asm(script_pub_key) | ||
if len(asm) == 2 and asm[0] == OP_RETURN: # OP_RETURN # noqa: F405 | ||
if type(asm[1]) != bytes: # noqa: E721 |
Check warning
Code scanning / pylint
Use isinstance() rather than type() for a typecheck. Warning
elif ( | ||
len(asm) == 5 and asm[0] == 1 and asm[3] == 2 and asm[4] == OP_CHECKMULTISIG # noqa: F405 | ||
): # Multi-sig | ||
if type(asm[2]) != bytes: # noqa: E721 |
Check warning
Code scanning / pylint
Use isinstance() rather than type() for a typecheck. Warning
pubkeyhash_encoding = True | ||
data_chunk_length = data_pubkey[0] # No ord() necessary. | ||
data_chunk = data_pubkey[1 : data_chunk_length + 1] | ||
if data_chunk[-8:] == config.PREFIX: |
Check warning
Code scanning / pylint
Unnecessary "else" after "break", remove the "else" and de-indent the code inside it. Warning
fee += vout_value | ||
|
||
address = get_address(script_pubkey, block_index) | ||
if not address: |
Check warning
Code scanning / pylint
Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it. Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
return block_count + blocks_behind | ||
|
||
|
||
class BackendHeight(metaclass=helpers.SingletonMeta): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh man, this is great
if util.enabled("multiple_dispenses"): | ||
outs = ledger.get_vouts(db, tx["tx_hash"]) | ||
if protocol.enabled("multiple_dispenses"): | ||
outs = ledger.ledger.get_vouts(db, tx["tx_hash"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a real nitpick but I don't love x.x
imports. feels redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but I'm totally fine with it!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah completely agree! I need to split ledger.py is several files.. will be ledger.balances.* ledger.transactions.* etc..
This reverts commit 288b1b2.
if protocol.enabled("utxo_support") and utxosinfo.is_utxo_format(address): | ||
field_name = "utxo" | ||
|
||
query = f""" |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
if protocol.enabled("utxo_support") and utxosinfo.is_utxo_format(address): | ||
field_name = "utxo" | ||
|
||
query = f""" |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
if protocol.enabled("utxo_support") and utxosinfo.is_utxo_format(address): | ||
field_name = "utxo" | ||
|
||
query = f""" |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
if protocol.enabled("utxo_support") and utxosinfo.is_utxo_format(address): | ||
field_name = "utxo" | ||
|
||
query = f""" |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
set_data.append("block_index = :block_index") | ||
bindings["block_index"] = CurrentState().current_block_index() | ||
set_data = ", ".join(set_data) | ||
sql = f"""UPDATE orders SET {set_data} WHERE tx_hash = :tx_hash""" # noqa S608 |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
def insert_record(db, table_name, record, event, event_info={}): # noqa: B006 | ||
fields = list(record.keys()) | ||
placeholders = ", ".join(["?" for _ in fields]) | ||
query = f"INSERT INTO {table_name} ({', '.join(fields)}) VALUES ({placeholders})" # noqa: S608 |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
cursor.execute("SELECT last_insert_rowid() AS rowid") | ||
inserted_rowid = cursor.fetchone()["rowid"] | ||
new_record = cursor.execute( | ||
f"SELECT * FROM {table_name} WHERE rowid = ?", # noqa: S608 |
Check warning
Code scanning / Bandit
Possible SQL injection vector through string-based query construction. Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️❤️❤️❤️❤️❤️
counterparty-rs
tocounterparty-core
lib/util.py
andledger.py