Skip to content

Commit

Permalink
lower-case all db column names
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Apr 2, 2024
1 parent 7253ddb commit 300c716
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 68 deletions.
4 changes: 2 additions & 2 deletions cashu/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def from_row(cls, row: Row):
return cls(
id=row["id"],
amount=row["amount"],
C_=row["C_"],
dleq=DLEQ(e=row["e"], s=row["s"]),
C_=row["c_"],
dleq=DLEQ(e=row["dleq_e"], s=row["dleq_s"]),
)


Expand Down
30 changes: 15 additions & 15 deletions cashu/mint/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ async def store_promise(
*,
db: Database,
amount: int,
B_: str,
C_: str,
b_: str,
c_: str,
id: str,
e: str = "",
s: str = "",
Expand All @@ -142,7 +142,7 @@ async def get_promise(
self,
*,
db: Database,
B_: str,
b_: str,
conn: Optional[Connection] = None,
) -> Optional[BlindedSignature]: ...

Expand Down Expand Up @@ -233,8 +233,8 @@ async def store_promise(
*,
db: Database,
amount: int,
B_: str,
C_: str,
b_: str,
c_: str,
id: str,
e: str = "",
s: str = "",
Expand All @@ -243,13 +243,13 @@ async def store_promise(
await (conn or db).execute(
f"""
INSERT INTO {table_with_schema(db, 'promises')}
(amount, B_, C_, e, s, id, created)
(amount, b_, c_, dleq_e, dleq_s, id, created)
VALUES (?, ?, ?, ?, ?, ?, ?)
""",
(
amount,
B_,
C_,
b_,
c_,
e,
s,
id,
Expand All @@ -261,15 +261,15 @@ async def get_promise(
self,
*,
db: Database,
B_: str,
b_: str,
conn: Optional[Connection] = None,
) -> Optional[BlindedSignature]:
row = await (conn or db).fetchone(
f"""
SELECT * from {table_with_schema(db, 'promises')}
WHERE B_ = ?
WHERE b_ = ?
""",
(str(B_),),
(str(b_),),
)
return BlindedSignature.from_row(row) if row else None

Expand Down Expand Up @@ -298,7 +298,7 @@ async def invalidate_proof(
await (conn or db).execute(
f"""
INSERT INTO {table_with_schema(db, 'proofs_used')}
(amount, C, secret, Y, id, witness, created, melt_quote)
(amount, c, secret, y, id, witness, created, melt_quote)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
""",
(
Expand Down Expand Up @@ -352,7 +352,7 @@ async def get_proofs_pending(
rows = await (conn or db).fetchall(
f"""
SELECT * from {table_with_schema(db, 'proofs_pending')}
WHERE Y IN ({','.join(['?']*len(Ys))})
WHERE y IN ({','.join(['?']*len(Ys))})
""",
tuple(Ys),
)
Expand All @@ -370,7 +370,7 @@ async def set_proof_pending(
await (conn or db).execute(
f"""
INSERT INTO {table_with_schema(db, 'proofs_pending')}
(amount, C, secret, Y, id, witness, created, melt_quote)
(amount, c, secret, y, id, witness, created, melt_quote)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
""",
(
Expand Down Expand Up @@ -668,7 +668,7 @@ async def get_proof_used(
row = await (conn or db).fetchone(
f"""
SELECT * from {table_with_schema(db, 'proofs_used')}
WHERE Y = ?
WHERE y = ?
""",
(Y,),
)
Expand Down
6 changes: 3 additions & 3 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ async def restore(
for output in outputs:
logger.trace(f"looking for promise: {output}")
promise = await self.crud.get_promise(
B_=output.B_, db=self.db, conn=conn
b_=output.B_, db=self.db, conn=conn
)
if promise is not None:
# BEGIN backwards compatibility mints pre `m007_proofs_and_promises_store_id`
Expand Down Expand Up @@ -974,8 +974,8 @@ async def _generate_promises(
await self.crud.store_promise(
amount=amount,
id=keyset_id,
B_=B_.serialize().hex(),
C_=C_.serialize().hex(),
b_=B_.serialize().hex(),
c_=C_.serialize().hex(),
e=e.serialize(),
s=s.serialize(),
db=self.db,
Expand Down
Loading

0 comments on commit 300c716

Please sign in to comment.