-
Notifications
You must be signed in to change notification settings - Fork 214
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
Only store unique store and forward messages #1862
Conversation
06bf879
to
3896e6e
Compare
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.
Awesome! Just a suggestion to use the database engine to do unique checking.
3896e6e
to
8cf9b7c
Compare
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.
Thanks - tested on my base node and this works - just need to complete the down migration
ALTER TABLE stored_messages | ||
ADD body_hash TEXT; | ||
|
||
CREATE UNIQUE INDEX uidx_stored_messages_body_hash ON stored_messages (body_hash); |
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.
Tested migration and works well (nulls are not counted towards the unique index as expected)
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.
That is great!
- These changes allow only unique messages to be stored by the store and forward system. - This is achieved by comparing the body hash of a new message to the hashes of the currently stored set of messages. Only if the body content is unique is the message stored by the store and forward database. - Modified the store and forward database insert_message test to also test the behaviour when a duplicate message is inserted.
8cf9b7c
to
3c96423
Compare
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.
👍
Description
Motivation and Context
Limit unnecessary storage of messages with duplicate content.
How Has This Been Tested?
Modified the store and forward database insert_message test to also test the behaviour when a duplicate message is inserted.
Types of changes
Checklist:
development
branch.cargo-fmt --all
before pushing.