Skip to content

Commit

Permalink
fix: pop goes the tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 2, 2022
1 parent e2e449b commit 96d65f8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions evm_trace/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ def get_gas_report(calltree: CallTreeNode) -> GasReport:
report = {
calltree.address: {calltree.calldata[:4]: [calltree.gas_cost] if calltree.gas_cost else []}
}
return merge_reports(report, *map(get_gas_report, calltree.calls))

report = merge_reports(report, *map(get_gas_report, calltree.calls))

return report


def merge_reports(*reports: List[GasReport]) -> GasReport:
def merge_reports(*reports: GasReport) -> GasReport:
"""
Merge method for merging a list of gas reports and combining a list of gas costs.
"""
if len(reports) < 1:
reports_ls = list(reports)
if len(reports_ls) < 1:
raise ValueError("Must be 2 or more reports to merge")
elif len(reports) == 1:
return reports[0]
merged_report: GasReport = copy.deepcopy(reports.pop(0))
elif len(reports_ls) == 1:
return reports_ls[0]

merged_report: GasReport = copy.deepcopy(reports_ls.pop(0))

if len(reports) < 1:
if len(reports_ls) < 1:
return merged_report

for report in reports:
for report in reports_ls:
for outer_key, inner_dict in report.items():
if outer_key not in merged_report:
merged_report[outer_key] = inner_dict
Expand Down

0 comments on commit 96d65f8

Please sign in to comment.