Ejemplo n.º 1
0
    def requestAndMine(self):
        while True:
            try:
                # This sections grabs pool adress and port from Duino-Coin GitHub file
                serverip = "https://raw.githubusercontent.com/revoxhere/duino-coin/gh-pages/serverip.txt"  # Serverip file
                with urllib.request.urlopen(serverip) as content:
                    content = (content.read().decode().splitlines()
                               )  # Read content and split into lines
                pool_address = content[0]  # Line 1 = pool address
                pool_port = content[1]  # Line 2 = pool port

                # This section connects and logs user to the server
                # Connect to the server
                self.soc.connect((str(pool_address), int(pool_port)))
                server_version = self.soc.recv(
                    3).decode()  # Get server version
                babylog.status("Server is on version: " + str(server_version))
                # Mining section
                while True:
                    buff = self.mine()
                    if 'Accepted' in buff:
                        babylog.status(buff)
                    elif 'Rejected' in buff:
                        babylog.warn(buff)
                    else:
                        babylog.warn('Empty buffer, likely error')

            except Exception as e:
                babylog.error("Error occured: " + str(e) +
                              ", restarting in 5s.")
                time.sleep(5)
                try:
                    self.soc.close()
                except Exception as e:
                    babylog.warn(str(e))
Ejemplo n.º 2
0
def stop():
    try:
        for m in miners:
            m.stop_mining()
            babylog.status('Stopped Mining on thread!')
        return '3 ,2, 1 aaand Done! Mining stopped! You can close this tab or window.'
    except NameError:
        babylog.warn('Tried to stop a non existent miner')
        return 'The miner has not started yet.'
Ejemplo n.º 3
0
 def start_mining(self):
     """Starts mining as a process"""
     try:
         self.proc.terminate()  # pylint: disable=access-member-before-definition
     except Exception:
         babylog.status('No previously running threads, OK!')
     finally:
         self.proc = multiprocessing.Process(  # pylint: disable=attribute-defined-outside-init
             target=self.requestAndMine,
             args=())
         self.proc.start()
Ejemplo n.º 4
0
 def pressed(self, instance):
     fname = self.name.text
     lname = self.last_name.text
     # print(fname,lname)
     negatives = ['no', 'false', 'n', 'nope']
     if lname.lower() in negatives:
         boolUseLowerDiff = False
     else:
         boolUseLowerDiff = True
     # Fetches the username and difficulty
     babylog.status('Mining for ' + fname)
     babylog.status('Using Lower Mining Difficulty: ' + lname)
     miner = Miner(fname, boolUseLowerDiff)
     miner.requestAndMine()
Ejemplo n.º 5
0
def checkLogs():
    babylog.status('Checking logs...')
    with open('miner.log') as l:
        text = l.read()
    head = """
     <!DOCTYPE html>
<html>
<body>
<pre> 
    """
    tail = """</pre>
</body>
</html>
    """
    return head + text + tail
Ejemplo n.º 6
0
def mining(username, UseLowerDiff):
    if UseLowerDiff == 'False':
        boolUseLowerDiff = False
    else:
        boolUseLowerDiff = True
    # Fetches the username and difficulty
    babylog.status('Mining for ' + username)
    babylog.status('Using Lower Mining Difficulty: ' + UseLowerDiff)
    cpus = os.cpu_count()
    for i in range(cpus):
        m = Miner(username, boolUseLowerDiff)
        m.start_mining()
        babylog.status('Mining Started on Thread {}!'.format(i))
        miners.append(m)
    return 'Wooohooo! Mining started! You can close this tab or window.'
Ejemplo n.º 7
0
def home():
    text = r"//\(oo)/\\ Congrats, the server is working! //\(oo)/\\"
    babylog.status('Server test succesful.')
    return text