-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix/duplication exception #89
Conversation
address_to_twitter_handles = { | ||
user["wallet_address"]: user["twitter_handle"] | ||
for user in self.synchronized_data.ceramic_db["users"] | ||
if user["wallet_address"] | ||
} | ||
|
||
# Ignore registration if both address and Twitter handle already exist | ||
if ( | ||
wallet_address in address_to_twitter_handles | ||
and address_to_twitter_handles[wallet_address] | ||
): | ||
return None |
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.
If the ceramic_db
contains two users with the same wallet address and different handles, then this logic might fail to register one of the handles.
Can this ever happen, i.e., the db containing two users with the same address and different handles?
If yes, is it intentional not to register one of the handles?
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.
We do not allow the same address being registered with two users. In fact, we have some logic to merge users that share the same address.
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.
Nice, so the wallet_address
is safe to be used as a unique ID here.
What worries me though is that we re-construct this mapping for every tweet:
IEKit/packages/valory/skills/twitter_scoring_abci/behaviours.py
Lines 666 to 671 in 5f90285
for tweet in tweets.values(): | |
author_id = tweet["author_id"] | |
twitter_name = tweet["username"] | |
new_points = tweet["points"] | |
wallet_address = self.get_registration(tweet["text"]) |
The address_to_twitter_handles
could be generated only once and then kept in memory and used on every iteration.
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.
We don't do it for every tweet , but for every registration tweet, which are not very common (users only post those tweets when they register to the service). Anyway, I also thought about keeping it in memory, but since this adds to the pile of data that the service needs to keep updated and in sync, and given that we are going to revamp the registration system with a proper signature-based one, I decided to go this way.
Proposed changes
Ignores twet registrations for addresses that have been already registered
Fixes
n/a
Types of changes
What types of changes does your code introduce? (A breaking change is a fix or feature that would cause existing functionality and APIs to not work as expected.)
Put an
x
in the box that appliesChecklist
Put an
x
in the boxes that apply.main
branch (left side). Also you should start your branch off ourmain
.Further comments
n/a