FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Correctly rotate hash keys by friscoMad · Pull Request #2422 · RocketMap/RocketMap · GitHub

Correctly rotate hash keys - #2422

Closed
friscoMad wants to merge 2 commits into
RocketMap:developfrom
friscoMad:frisco-keyScheduler
Closed

Correctly rotate hash keys#2422
friscoMad wants to merge 2 commits into
RocketMap:developfrom
friscoMad:frisco-keyScheduler

Conversation

Copy link
Copy Markdown
Contributor

Description

Previously we had keyscheduler logic all over the place but we can move all to a single point in apiRequest and it makes a lot more sense.

Motivation and Context

Did this changes for the future api but most of them can be ported back to current api so it will rotate the keys more evenly (instead of changing the key per gmo it does change per request).

The next step should be doing the same for proxies buy I wanted this merged before adding more things.

How Has This Been Tested?

Just some minutes in my test instance, but my main instance is running the branch from where I ported the code.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

sebastienvercammen left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think the intent is good, but this should wait until #2424 is merged so we have a proper scope to put the encounters: the account.

Scanner > account > request > response first parsed by the account used for the request to update its status > response passed to caller.

Comment thread pogom/apiRequests.py
from pgoapi.hash_server import BadHashRequestException, HashingOfflineException

log = logging.getLogger(__name__)
_key_scheduler = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We shouldn't introduce globals.

Comment thread pogom/apiRequests.py

def configure(key_scheduler):
global _key_scheduler
_key_scheduler = key_scheduler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This method is only here because of the global, we should use a proper scope.

Comment thread pogom/schedulers.py
self.curr_key = self.key_cycle.next()
return self.curr_key

def update_hash_stats(self, key, remaining, maximum, expiration):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

i dont see the request for the token anymore? did you triple check with several keys and instances that none of the values jumps around?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I did not triple check anything and does not have several keys to test 😄
I am not really sure about what are your fears, the current desing of api does not return the data with the response so it is not thread safe, we just get the data after the request has been done but if there was a context switch the data we retrieve it is always from the last request, at least we are not mixing the key from the request with the data we are reading as they could be different, we just store the data (token and headers) the api has when this is called.
Proper solution would need to change the API to be thread safe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

yup and because we store just the last request the token is needed to identify which key made the request, otherwise its failing to allocate the correct key for the value, i have some spare time left tomomorrow and will check if this is going ok or not.

Comment thread pogom/apiRequests.py
remaining = HashServer.status.get('remaining', 0)
maximum = HashServer.status.get('maximum', 0)
expiration = HashServer.status.get('expiration', None)
_key_scheduler.update_hash_stats(key, remaining, maximum, expiration)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@Alderon86 I am getting the key directly from the status so even if it is not the one that made the request we store the data correctly.

Copy link
Copy Markdown
Contributor Author

Closing this as I will no longer be supporting my PRs, if any one wants to take over please do so.

friscoMad closed this Mar 4, 2018
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL