Skip to content
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

i suggest to work with threads in the mining process #8

Open
Sanix-Darker opened this issue Mar 15, 2019 · 2 comments
Open

i suggest to work with threads in the mining process #8

Sanix-Darker opened this issue Mar 15, 2019 · 2 comments
Labels
enhancement New feature or request hacktoberfest

Comments

@Sanix-Darker
Copy link

When a mining started, it can take too long depending on how the difficulty have been configured, so when that operation start the api is waiting the process end before return a response, it's same when trying to access the api with any other endpoint /chain,... etc, so i suggest to use threads as i do:

from threading import Thread

def mine():
    .... mine() content....

...... some code here...
@app.route.....
def request_for_mine():
    .... some code here....
    # Launch the thread for the mine process, so that the API will be still available 
    Thread(target = mine).start() 

    return response
@Sanix-Darker Sanix-Darker changed the title Work with Threads Work with threads in mining Mar 15, 2019
@Sanix-Darker Sanix-Darker changed the title Work with threads in mining i suggest to work with threads in the mining process Mar 15, 2019
@satwikkansal
Copy link
Owner

satwikkansal commented Mar 15, 2019

Nice idea to perform the execution on different threads. But some API responses are dependent on the entire execution (for example, /chain endpoint), so they can't be dealt this way.

Also, expected behavior for a client is to call /mine, and then get the chain, which again can't be dealt on different threads (the chain won't be updated until mine is finished).

Edit: But yes, the mining figuring out the nonce process can be run parallely using multiprocessing module which can take advantage of multiple CPU cores.

@satwikkansal satwikkansal added the enhancement New feature or request label Mar 15, 2019
@gerardkm94
Copy link

A nice approach for handling operations as mining will be the use of RabbitMQ or event data driven architectures. Of course is a big enhacement, but definetly will be necessary in a real time implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants