-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendezvous Certificates #7517
Closed
+435
−3
Closed
Rendezvous Certificates #7517
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91d360a
Upgrade PyQt, Yarl, and LibTorrent dependencies
InvictusRMC 066a02b
Add initial rendezvous design
InvictusRMC 31dbcc8
Finalize rendezvous design
InvictusRMC b3e79ca
Add rendezvous tests
InvictusRMC f1120ee
Move tests to seperate class
InvictusRMC 427f6c5
Use db name const + move tests
InvictusRMC 263b293
Revert "Upgrade PyQt, Yarl, and LibTorrent dependencies"
InvictusRMC eb0b667
Remove unnecessary override
InvictusRMC 6dc9d4c
Address requested changes and comments
InvictusRMC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the logic for
rendezvous_request
could be relocated to theon_introduction_response
function. This could simplify interactions by eliminating the need to extendintroduction_request
. As a bonus, this change might allow us to retain the previous community ID.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current approach is still compatible! Older peers will just ignore the extra bytes. I could drop this entire extra logic though. We can get it to work through only separate payloads.