feat: store message size
This commit is contained in:
parent
f331a19d75
commit
c488f5d5e0
4 changed files with 12 additions and 5 deletions
7
crud.py
7
crud.py
|
|
@ -82,11 +82,12 @@ async def create_event(relay_id: str, e: NostrEvent):
|
||||||
created_at,
|
created_at,
|
||||||
kind,
|
kind,
|
||||||
content,
|
content,
|
||||||
sig
|
sig,
|
||||||
|
size
|
||||||
)
|
)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(relay_id, e.id, e.pubkey, e.created_at, e.kind, e.content, e.sig),
|
(relay_id, e.id, e.pubkey, e.created_at, e.kind, e.content, e.sig, e.size_bytes),
|
||||||
)
|
)
|
||||||
|
|
||||||
# todo: optimize with bulk insert
|
# todo: optimize with bulk insert
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ async def m001_initial(db):
|
||||||
created_at {db.big_int} NOT NULL,
|
created_at {db.big_int} NOT NULL,
|
||||||
kind INT NOT NULL,
|
kind INT NOT NULL,
|
||||||
content TEXT NOT NULL,
|
content TEXT NOT NULL,
|
||||||
sig TEXT NOT NULL
|
sig TEXT NOT NULL,
|
||||||
|
size {db.big_int} DEFAULT 0
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,11 @@ class NostrEvent(BaseModel):
|
||||||
id = hashlib.sha256(data.encode()).hexdigest()
|
id = hashlib.sha256(data.encode()).hexdigest()
|
||||||
return id
|
return id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size_bytes(self) -> int:
|
||||||
|
s = json.dumps(dict(self), separators=(",", ":"), ensure_ascii=False)
|
||||||
|
return len(s.encode())
|
||||||
|
|
||||||
def is_replaceable_event(self) -> bool:
|
def is_replaceable_event(self) -> bool:
|
||||||
return self.kind in [0, 3]
|
return self.kind in [0, 3]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
<q-tab-panel name="payment">
|
<q-tab-panel name="payment">
|
||||||
<div v-if="relay">
|
<div v-if="relay">
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
<div class="col-3 q-pr-lg q-pb-md">Free storage:</div>
|
<div class="col-3 q-pr-lg q-pb-md">Free Storage:</div>
|
||||||
<div class="col-2 q-pr-lg">
|
<div class="col-2 q-pr-lg">
|
||||||
<q-input
|
<q-input
|
||||||
filled
|
filled
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue