storage module

This commit is contained in:
Dobromir Popov
2024-11-14 15:39:35 +02:00
parent eebba5d6b4
commit b623c4cb15
6 changed files with 427 additions and 418 deletions

View File

@ -1,7 +1,7 @@
import os
import asyncio
from pathlib import Path
from .storage import store_transaction, prisma_client
from .storage import Storage
from .SolanaAPI import SolanaAPI
LOG_DIRECTORY = "./logs"
@ -28,7 +28,7 @@ async def process_log_file(file_path):
transaction_data = await solana_api.process_wh(data)
# Check if the transaction already exists
existing_transaction = await prisma_client.transaction.find_first(
existing_transaction = await Storage.get_prisma().transaction.find_first(
where={'solana_signature': solana_signature}
)
@ -46,7 +46,8 @@ async def process_log_file(file_path):
'solana_signature': solana_signature,
'details': details
}
await store_transaction(transaction_data)
storage = Storage()
await storage.store_transaction(transaction_data)
# Rename the file to append '_saved'
new_file_path = file_path.with_name(file_path.stem + "_saved" + file_path.suffix)