File size: 712 Bytes
29cdc9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import hashlib
import json
import logging
from datetime import datetime

log = logging.getLogger("VitalisCore")

class LedgerService:
    def __init__(self, ledger_file="production_ledger.json"):
        self.ledger_file = ledger_file

    def record_merge(self, module_name: str, file_path: str):
        with open(file_path, "rb") as f:
            file_hash = hashlib.sha256(f.read()).hexdigest()
        entry = {
            "timestamp": datetime.now().isoformat(),
            "module": module_name,
            "hash": file_hash
        }
        with open(self.ledger_file, "a") as f:
            f.write(json.dumps(entry) + "\n")
        log.info(f"LEGER_RECORDED: {module_name} with hash {file_hash}")