Spaces:
Build error
Build error
Commit ·
da70460
1
Parent(s): 690acd1
Upload folder using huggingface_hub
Browse files
app/api/routes_onchain.py
CHANGED
|
@@ -16,7 +16,7 @@ why there is no tenant_id to enforce here.
|
|
| 16 |
|
| 17 |
import logging
|
| 18 |
|
| 19 |
-
from fastapi import APIRouter, Depends, HTTPException
|
| 20 |
from pydantic import BaseModel, field_validator
|
| 21 |
from sqlalchemy.orm import Session
|
| 22 |
|
|
@@ -68,6 +68,7 @@ class RationaleResponse(BaseModel):
|
|
| 68 |
@router.post("/onchain/rationale", status_code=201)
|
| 69 |
async def persist_rationale(
|
| 70 |
req: RationaleRequest,
|
|
|
|
| 71 |
db: Session = Depends(get_db),
|
| 72 |
):
|
| 73 |
"""Store the plaintext behind an anchored `rationale_hash`.
|
|
@@ -94,6 +95,11 @@ async def persist_rationale(
|
|
| 94 |
"an anchored hash's preimage cannot be overwritten"
|
| 95 |
),
|
| 96 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
return {"status": "already_recorded", "rationale_hash": req.rationale_hash}
|
| 98 |
|
| 99 |
row = OnchainRationaleDB(
|
|
|
|
| 16 |
|
| 17 |
import logging
|
| 18 |
|
| 19 |
+
from fastapi import APIRouter, Depends, HTTPException, Response
|
| 20 |
from pydantic import BaseModel, field_validator
|
| 21 |
from sqlalchemy.orm import Session
|
| 22 |
|
|
|
|
| 68 |
@router.post("/onchain/rationale", status_code=201)
|
| 69 |
async def persist_rationale(
|
| 70 |
req: RationaleRequest,
|
| 71 |
+
response: Response,
|
| 72 |
db: Session = Depends(get_db),
|
| 73 |
):
|
| 74 |
"""Store the plaintext behind an anchored `rationale_hash`.
|
|
|
|
| 95 |
"an anchored hash's preimage cannot be overwritten"
|
| 96 |
),
|
| 97 |
)
|
| 98 |
+
# The route decorator's status_code=201 is FastAPI's default for
|
| 99 |
+
# every plain-dict return from this handler, including this one --
|
| 100 |
+
# it must be overridden explicitly here or a replayed post reports
|
| 101 |
+
# itself as newly Created.
|
| 102 |
+
response.status_code = 200
|
| 103 |
return {"status": "already_recorded", "rationale_hash": req.rationale_hash}
|
| 104 |
|
| 105 |
row = OnchainRationaleDB(
|