removed btc and stopped delivering pow hash
This commit is contained in:
parent
973b8583b6
commit
c13a742335
@ -1 +0,0 @@
|
||||
Subproject commit a74e826e9c69e643ead7950f9f76a05ab8664ddc
|
@ -1,44 +0,0 @@
|
||||
'''
|
||||
Onionr - P2P Microblogging Platform & Social network
|
||||
|
||||
Handle bitcoin operations
|
||||
'''
|
||||
'''
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
from bitpeer.node import *
|
||||
from bitpeer.storage.shelve import ShelveStorage
|
||||
import logging, time
|
||||
import socks, sys
|
||||
class OnionrBTC:
|
||||
def __init__(self, lastBlock='00000000000000000021ee6242d08e3797764c9258e54e686bc2afff51baf599', lastHeight=510613, torP=9050):
|
||||
stream = logging.StreamHandler()
|
||||
logger = logging.getLogger('halfnode')
|
||||
logger.addHandler(stream)
|
||||
logger.setLevel (10)
|
||||
|
||||
LASTBLOCK = lastBlock
|
||||
LASTBLOCKINDEX = lastHeight
|
||||
self.node = Node ('BTC', ShelveStorage ('data/btc-blocks.db'), lastblockhash=LASTBLOCK, lastblockheight=LASTBLOCKINDEX, torPort=torP)
|
||||
|
||||
self.node.bootstrap ()
|
||||
self.node.connect ()
|
||||
self.node.loop ()
|
||||
|
||||
if __name__ == "__main__":
|
||||
torPort = int(sys.argv[1])
|
||||
bitcoin = OnionrBTC(torPort)
|
||||
while True:
|
||||
print(bitcoin.node.getBlockHash(bitcoin.node.getLastBlockHeight())) # Using print on purpose, do not change to logger
|
||||
time.sleep(5)
|
@ -21,7 +21,7 @@ import sqlite3, os, sys, time, math, base64, tarfile, getpass, simplecrypt, hash
|
||||
#from Crypto.Cipher import AES
|
||||
#from Crypto import Random
|
||||
|
||||
import onionrutils, onionrcrypto, onionrproofs, btc, onionrevents as events
|
||||
import onionrutils, onionrcrypto, onionrproofs, onionrevents as events
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
try:
|
||||
@ -461,6 +461,7 @@ class Core:
|
||||
try:
|
||||
peerList.append(self._crypto.pubKey + '-' + self._crypto.pubKeyPowToken)
|
||||
except TypeError:
|
||||
print('what')
|
||||
pass
|
||||
else:
|
||||
peerList.append(self._crypto.pubKey)
|
||||
|
@ -28,7 +28,7 @@ class OnionrCrypto:
|
||||
self.privKey = None
|
||||
|
||||
self.pubKeyPowToken = None
|
||||
self.pubKeyPowHash = None
|
||||
#self.pubKeyPowHash = None
|
||||
|
||||
self.HASH_ID_ROUNDS = 2000
|
||||
|
||||
@ -41,8 +41,7 @@ class OnionrCrypto:
|
||||
try:
|
||||
with open(self.keyPowFile, 'r') as powFile:
|
||||
data = powFile.read()
|
||||
self.pubKeyPowHash = data.split('-')[0]
|
||||
self.pubKeyPowToken = data.split('-')[1]
|
||||
self.pubKeyPowToken = data
|
||||
except (FileNotFoundError, IndexError):
|
||||
pass
|
||||
else:
|
||||
|
@ -19,7 +19,7 @@
|
||||
'''
|
||||
|
||||
import nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, logger, sys
|
||||
import btc, core
|
||||
import core
|
||||
|
||||
class POW:
|
||||
def pow(self, reporting = False):
|
||||
@ -30,20 +30,8 @@ class POW:
|
||||
answer = ''
|
||||
heartbeat = 200000
|
||||
hbCount = 0
|
||||
blockCheck = 300000 # How often the hasher should check if the bitcoin block is updated (slows hashing but prevents less wasted work)
|
||||
blockCheckCount = 0
|
||||
block = '' #self.bitcoinNode.getBlockHash(self.bitcoinNode.getLastBlockHeight())
|
||||
myCore = core.Core()
|
||||
while self.hashing:
|
||||
'''
|
||||
if blockCheckCount == blockCheck:
|
||||
if self.reporting:
|
||||
logger.debug('Refreshing Bitcoin block')
|
||||
block = '' #self.bitcoinNode.getBlockHash(self.bitcoinNode.getLastBlockHeight())
|
||||
blockCheckCount = 0
|
||||
blockCheckCount += 1
|
||||
hbCount += 1
|
||||
'''
|
||||
rand = nacl.utils.random()
|
||||
token = nacl.hash.blake2b(rand + self.data).decode()
|
||||
#print(token)
|
||||
@ -60,7 +48,7 @@ class POW:
|
||||
logger.info('took ' + str(endTime - startTime) + ' seconds', timestamp=True)
|
||||
self.result = (token, rand)
|
||||
|
||||
def __init__(self, data, bitcoinNode=''):
|
||||
def __init__(self, data):
|
||||
self.foundHash = False
|
||||
self.difficulty = 0
|
||||
self.data = data
|
||||
@ -80,7 +68,6 @@ class POW:
|
||||
|
||||
self.mainHash = '0000000000000000000000000000000000000000000000000000000000000000'#nacl.hash.blake2b(nacl.utils.random()).decode()
|
||||
self.puzzle = self.mainHash[0:self.difficulty]
|
||||
self.bitcoinNode = bitcoinNode
|
||||
#logger.debug('trying to find ' + str(self.mainHash))
|
||||
tOne = threading.Thread(name='one', target=self.pow, args=(True,))
|
||||
tTwo = threading.Thread(name='two', target=self.pow, args=(True,))
|
||||
|
Loading…
Reference in New Issue
Block a user