-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial rendezvous design Finalize rendezvous design Add rendezvous tests Move tests to seperate class Use db name const + move tests Revert "Upgrade PyQt, Yarl, and LibTorrent dependencies" This reverts commit 91d360a. Remove unnecessary override Address requested changes and comments
- Loading branch information
1 parent
46085b6
commit e99dba8
Showing
13 changed files
with
435 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions
36
src/tribler/core/components/popularity/rendezvous/db/database.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
from pony.orm import Database, db_session | ||
|
||
from tribler.core.components.metadata_store.db.orm_bindings import misc | ||
from tribler.core.components.popularity.rendezvous.db.orm_bindings import certificate | ||
from tribler.core.utilities.utilities import MEMORY_DB | ||
|
||
|
||
class RendezvousDatabase: | ||
DB_VERSION = 0 | ||
|
||
def __init__(self, db_path: Union[Path, type(MEMORY_DB)]): | ||
|
||
self.database = Database() | ||
|
||
self.MiscData = misc.define_binding(self.database) | ||
self.Certificate = certificate.define_binding(self.database) | ||
|
||
if db_path is MEMORY_DB: | ||
create_db = True | ||
db_path_string = ":memory:" | ||
else: | ||
create_db = not db_path.is_file() | ||
db_path_string = str(db_path) | ||
|
||
self.database.bind(provider='sqlite', filename=db_path_string, create_db=create_db, timeout=120.0) | ||
self.database.generate_mapping(create_tables=create_db) | ||
|
||
if create_db: | ||
with db_session: | ||
self.MiscData(name="db_version", value=str(self.DB_VERSION)) | ||
|
||
def shutdown(self) -> None: | ||
self.database.disconnect() |
Empty file.
9 changes: 9 additions & 0 deletions
9
src/tribler/core/components/popularity/rendezvous/db/orm_bindings/certificate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pony.orm import Required, db_session | ||
|
||
|
||
def define_binding(db): | ||
class RendezvousCertificate(db.Entity): | ||
public_key = Required(bytes, index=True) | ||
counter = Required(int) | ||
|
||
return RendezvousCertificate |
9 changes: 9 additions & 0 deletions
9
src/tribler/core/components/popularity/rendezvous/db/orm_bindings/misc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pony.orm import Optional, PrimaryKey | ||
|
||
|
||
def define_binding(db): | ||
class MiscData(db.Entity): | ||
name = PrimaryKey(str) | ||
value = Optional(str) | ||
|
||
return MiscData |
Oops, something went wrong.