WIP: Fix DB writing
This commit is contained in:
parent
fe6cd4dcdb
commit
8281d123ab
@ -1,4 +1,3 @@
|
||||
import json
|
||||
from typing import List
|
||||
|
||||
from mev_inspect.models.classified_traces import ClassifiedTraceModel
|
||||
@ -22,9 +21,30 @@ def write_classified_traces(
|
||||
db_session,
|
||||
classified_traces: List[ClassifiedTrace],
|
||||
) -> None:
|
||||
models = [
|
||||
ClassifiedTraceModel(**json.loads(trace.json())) for trace in classified_traces
|
||||
]
|
||||
models = []
|
||||
for trace in classified_traces:
|
||||
models.append(
|
||||
ClassifiedTraceModel(
|
||||
**{
|
||||
"transaction_hash": trace.transaction_hash,
|
||||
"block_number": trace.block_number,
|
||||
"classification": trace.classification.value,
|
||||
"trace_type": trace.type.value,
|
||||
"trace_address": trace.trace_address,
|
||||
"protocol": str(trace.protocol),
|
||||
"abi_name": trace.abi_name,
|
||||
"function_name": trace.function_name,
|
||||
"function_signature": trace.function_signature,
|
||||
"inputs": trace.inputs,
|
||||
"from_address": trace.from_address,
|
||||
"to_address": trace.to_address,
|
||||
"gas": trace.gas,
|
||||
"value": trace.value,
|
||||
"gas_used": trace.gas_used,
|
||||
"error": trace.error,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
db_session.bulk_save_objects(models)
|
||||
db_session.commit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user