Merge pull request #50 from flashbots/add-protocol-to-stats

Add protocol to the stats output of inspect block
This commit is contained in:
Robert Miller 2021-08-16 16:27:09 -04:00 committed by GitHub
commit d677e0b6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,16 +123,19 @@ def get_stats(classified_traces) -> dict:
stats: dict = {}
for trace in classified_traces:
protocol = str(trace.protocol)
abi_name = trace.abi_name
classification = trace.classification.value
signature = trace.function_signature
abi_name_stats = stats.get(abi_name, {})
protocol_stats = stats.get(protocol, {})
abi_name_stats = protocol_stats.get(abi_name, {})
class_stats = abi_name_stats.get(classification, {})
signature_count = class_stats.get(signature, 0)
class_stats[signature] = signature_count + 1
abi_name_stats[classification] = class_stats
stats[abi_name] = abi_name_stats
protocol_stats[abi_name] = abi_name_stats
stats[protocol] = protocol_stats
return stats