Crypto-Expert / stratum-mining

AIO Stratum mining server for various coins
Other
365 stars 348 forks source link

Adding twisted.internet.defer.DeferredLock() to BitcoinRPC._call() #352

Closed tuaris closed 9 years ago

tuaris commented 10 years ago

I've come across a problem where the wallet daemon may get DoS'd when a miner is finding valid block very quickly for a low difficulty coin. I am wondering if anyone has any thoughts on the side effects that may result from implementing the following code changes/additions:

In, "lib/bitcoin_rpc.py":

Add:

    def __init__(self, host, port, username, password):
                ...
        self._lock = defer.DeferredLock()
               ...

Then change

    def _call(self, method, params):
                ...
        return self._lock.run(self._call_raw, json.dumps({
                'jsonrpc': '2.0',
                'method': method,
                'params': params,
                'id': '1',
            }))

I am still testing and so far I have not seen any issues. Any opinions and thoughts would be appreciated.

ahmedbodi commented 10 years ago

That looks like it might work okay

ahmedbodi commented 9 years ago

refactor done here: https://github.com/Multicoin-co/stratum-mining/pull/2 now you can specify your own diff1 and algo