示例#1
0
文件: app.py 项目: pdxwebdev/yadacoin
    def init_config(self, options):
        if not path.isfile(options.config):
            self.config = yadacoin.core.config.Config.generate()
            try:
                os.makedirs(os.path.dirname(options.config))
            except:
                pass
            with open(options.config, 'w') as f:
                f.write(self.config.to_json())

        with open(options.config) as f:
            self.config = yadacoin.core.config.Config(json.loads(f.read()))
            # Sets the global var for all objects
            yadacoin.core.config.CONFIG = self.config
            self.config.debug = options.debug
            # force network, command line one takes precedence
            if options.network != '':
                self.config.network = options.network

        self.config.reset = options.reset
        self.config.pyrx = pyrx.PyRX()
        self.config.pyrx.get_rx_hash(
            'header',
            binascii.unhexlify(
                '4181a493b397a733b083639334bc32b407915b9a82b7917ac361816f0a1f5d4d'
            ), 4)
示例#2
0
 def generate_hash_from_header(self, height, header, nonce):
     if not hasattr(Block, 'pyrx'):
         Block.pyrx = pyrx.PyRX()
     header = header.format(nonce=nonce)
     if height >= CHAIN.RANDOMX_FORK:
         seed_hash = binascii.unhexlify('4181a493b397a733b083639334bc32b407915b9a82b7917ac361816f0a1f5d4d') #sha256(yadacoin65000)
         bh = Block.pyrx.get_rx_hash(header, seed_hash, height)
         hh = binascii.hexlify(bh).decode()
         return hh
     else:
         return hashlib.sha256(hashlib.sha256(header.encode('utf-8')).digest()).digest()[::-1].hex()
 def __init__(
     self,
     pool='',
     address='',
     cores=multiprocessing.cpu_count() - 2,
     work_size=1000,
     debug=False,
 ):
     self.pool = pool
     self.address = address
     self.cores = int(cores)
     self.work_size = int(work_size)
     self.debug = bool(int(debug))
     self.data = None
     self.nonces = []
     self.pyrx = pyrx.PyRX()
示例#4
0
    def init_config_properties(self):
        self.config.mongo = Mongo()
        self.config.http_client = AsyncHTTPClient()
        self.config.BU = yadacoin.core.blockchainutils.BlockChainUtils()
        self.config.TU = yadacoin.core.transactionutils.TU
        yadacoin.core.blockchainutils.set_BU(self.config.BU)  # To be removed
        self.config.GU = GraphUtils()
        self.config.LatestBlock = LatestBlock
        tornado.ioloop.IOLoop.current().run_sync(
            self.config.LatestBlock.block_checker)
        self.config.consensus = tornado.ioloop.IOLoop.current().run_sync(
            Consensus.init_async)
        self.config.cipher = Crypt(self.config.wif)
        if 'node' in self.config.modes:
            self.config.pyrx = pyrx.PyRX()
            self.config.pyrx.get_rx_hash(
                'header',
                binascii.unhexlify(
                    '4181a493b397a733b083639334bc32b407915b9a82b7917ac361816f0a1f5d4d'
                ), 4)
            self.config.nodeServer = NodeSocketServer
            self.config.nodeShared = NodeRPC
            self.config.nodeClient = NodeSocketClient()

            for x in [Seed, SeedGateway, ServiceProvider, User]:
                if x.__name__ not in self.config.nodeClient.outbound_streams:
                    self.config.nodeClient.outbound_ignore[x.__name__] = {}
                if x.__name__ not in self.config.nodeClient.outbound_streams:
                    self.config.nodeClient.outbound_pending[x.__name__] = {}
                if x.__name__ not in self.config.nodeClient.outbound_streams:
                    self.config.nodeClient.outbound_streams[x.__name__] = {}
            for x in [Seed, SeedGateway, ServiceProvider, User]:
                if x.__name__ not in self.config.nodeServer.inbound_pending:
                    self.config.nodeServer.inbound_pending[x.__name__] = {}
                if x.__name__ not in self.config.nodeServer.inbound_streams:
                    self.config.nodeServer.inbound_streams[x.__name__] = {}
            self.config.nodeServer().listen(self.config.peer_port)

        self.config.websocketServer = RCPWebSocketServer
        self.config.app_log = logging.getLogger('tornado.application')
        if 'web' in self.config.modes:
            for x in [User, Group]:
                if x.__name__ not in self.config.websocketServer.inbound_streams:
                    self.config.websocketServer.inbound_streams[
                        x.__name__] = {}
        if 'test' in self.config.modes:
            return
示例#5
0
    def home(self):
        self.logo = QLabel(self)
        self.logo.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'yadacoinlogo.png')))
        self.logo.move(0, -35)
        self.logo.resize(800, 300)
        self.logo.show()

        xanchor = 300
        yanchor = 165
        pooltext = QLabel(self)
        pooltext.setText('Pool:')
        pooltext.move(xanchor - 32, yanchor + 35)
        pooltext.show()
        corestext = QLabel(self)
        corestext.setText('Cores:')
        corestext.move(xanchor - 32, yanchor + 75)
        corestext.show()
        corestext = QLabel(self)
        corestext.setText('Address:')
        corestext.move(xanchor + 50, yanchor + 75)
        corestext.show()
        corestext = QLabel(self)
        corestext.setText('WIF/Seed:')
        corestext.move(xanchor - 32, yanchor + 115)
        corestext.show()
        self.nonces = []
        self.work_size = 10000
        self.pool = QLineEdit(self)
        self.pool.setText('https://yadacoin.io')
        self.pool.move(xanchor + 10, yanchor + 35)
        self.pool.resize(225, 30)
        self.address = QLineEdit(self)
        self.address.setText(self.config.address)
        self.address.move(xanchor + 115, yanchor + 75)
        self.address.resize(325, 30)
        self.address.setReadOnly(True)
        self.address.setStyleSheet(
            "background-color: rgb(200, 200, 200); color: rgb(100, 100, 100); border: none;"
        )
        self.wif = QLineEdit(self)
        self.wif.setText(self.config.wif)
        self.wif.move(xanchor + 40, yanchor + 115)
        self.wif.resize(460, 30)
        self.wif.setReadOnly(True)
        self.wif.setStyleSheet(
            "background-color: rgb(200, 200, 200); color: rgb(100, 100, 100); border: none;"
        )
        self.cores = QLineEdit(self)
        self.cores.setText(str(multiprocessing.cpu_count() - 2))
        self.cores.move(xanchor + 15, yanchor + 75)
        self.cores.resize(25, 30)
        self.btn = QPushButton("Start mining", self)
        self.btn.move(xanchor + 255, yanchor + 35)
        self.btn.clicked.connect(self.start_mine)
        self.stopbtn = QPushButton("Stop mining", self)
        self.stopbtn.move(xanchor + 375, yanchor + 35)
        self.stopbtn.clicked.connect(self.stop_mine)
        self.stopbtn.setDisabled(True)
        self.timer = QTimer(self)
        self.timer.setSingleShot(False)
        self.timer.timeout.connect(self.mine)
        self.running_processes = []
        self.hashrate = QLabel(self)
        self.hashrate.move(25, yanchor + 75)
        self.pyrx = pyrx.PyRX()
        self.show()
示例#6
0
import pyrx
import binascii

assert pyrx.__version__ >= '0.0.3'

expected = [
        '0b3d9586ee70d69b2d50cd3f1a998abfd86b61d9d5a70e05e61ffcf1d7f865e7',
        'aa552e647873ed03c2a8d0712f0821cf7d7183b5ee8e1522e33ac686b61d618d',
        '7c81a6507ad86760c105e0ad192be79fa5e176490cd3a5ca7e79d2619d49b9c9',
        '2db4f3e131fdcce6116de0ca58629f5f6c0e6c31c59dca2513ae99b2f4156422',
        'b48299ccbe5ea2b1b8e8b195d5d8cf785633b6f2bb7f3c0e2f6e766042dd112d'
        ]

seed_hash = binascii.unhexlify('63eceef7919087068ac5d1b7faffa23fc90a58ad0ca89ecb224a2ef7ba282d48')
p = pyrx.PyRX()
for x in range(5000000):
    m = "Hello RandomX {}".format(x)
    print("Hashing: {}".format(m))
    if x == 0:
        print("(first takes a while, please wait)")
    h = 1 + x
    bh = p.get_rx_hash(m, seed_hash, h)
    hh = binascii.hexlify(bh).decode()
    print("Result: {}".format(hh))
    #assert hh == expected[x]