feat: store message size

This commit is contained in:
Vlad Stan 2023-02-09 15:16:22 +02:00
parent f331a19d75
commit c488f5d5e0
4 changed files with 12 additions and 5 deletions

View file

@ -116,6 +116,11 @@ class NostrEvent(BaseModel):
id = hashlib.sha256(data.encode()).hexdigest()
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:
return self.kind in [0, 3]