Bitcoin Forum
June 22, 2018, 07:20:31 PM *
News: Latest stable version of Bitcoin Core: 0.16.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Phoenix Patch to allow fallback to primary pool  (Read 636 times)
generalfault
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile WWW
August 19, 2011, 01:24:12 PM
 #1

Ok, so this is a patch for phoenix 1.6.1 that allows it to fallback to the primary pool after a certain number of getworks. (just like poclbm and others.)

I don't have full permissions so maybe someone will be nice enough to move it over to the phoenix thread.

Code:
diff -Naur phoenix-1.6.1/Miner.py phoenix-test/Miner.py
--- phoenix-1.6.1/Miner.py 2011-08-15 13:27:10.000000000 -0500
+++ phoenix-test/Miner.py 2011-08-18 10:34:50.000000000 -0500
@@ -42,6 +42,7 @@
         self.idle = True
         self.cores = []
         self.backup = False
+ self.backupLife = 0
         self.failures = 0
         self.lastMetaRate = 0.0
         self.lastRateUpdate = time()
@@ -65,6 +66,25 @@
     def onWork(self, work):
         self.logger.reportDebug('Server gave new work; passing to WorkQueue')
         self.queue.storeWork(work)
+        if self.backup:
+            #When the backup life reaches 0, switch back to the primary pool
+            if (self.backupLife <= 0):
+                #disconnect and set connection to none
+                self.connection.disconnect()
+                self.connection = None
+               
+                #log
+                self.logger.log("Backup Lifespan finished,")
+                self.logger.log("attempting to return to primary server.")
+               
+                #reset failure count and return to primary server
+                self.failures = 0
+                self.backup = False
+                self.connection = self.options.makeConnection(self)
+                self.connection.connect()
+            else:
+                self.backupLife -= 1
+               
     def onLongpoll(self, lp):
         self.logger.reportType('RPC' + (' (+LP)' if lp else ''))
     def onPush(self, ignored):
@@ -73,9 +93,10 @@
         self.logger.log(message)
     def onDebug(self, message):
         self.logger.reportDebug(message)
-   
+
     def failoverCheck(self):
         if self.backup:
+            #The backup pool must fail 3 times before moving to the backup pool
             if (self.failures >= 1):
                 #disconnect and set connection to none
                 self.connection.disconnect()
@@ -106,6 +127,10 @@
                 #reset failure count and connect to backup server
                 self.failures = 0
                 self.backup = True
+ self.backupLife = 20
+                if self.options.backupLife is not None:
+                    self.backupLife = self.options.backupLife
+
                 self.connection = self.options.makeConnection(self, True)
                 self.connection.connect()
             else:
diff -Naur phoenix-1.6.1/phoenix.py phoenix-test/phoenix.py
--- phoenix-1.6.1/phoenix.py 2011-08-15 13:27:10.000000000 -0500
+++ phoenix-test/phoenix.py 2011-08-18 10:31:29.000000000 -0500
@@ -40,6 +40,7 @@
         self.parsedSettings = None
         self.url = None
         self.url2 = None
+ self.backupLife = None
         self.logger = None
         self.kernel = None
         self.queue = None
@@ -57,6 +58,9 @@
         parser.add_option("-b", "--backupurl", dest="url2", default=None,
             help="the URL of the backup mining server to work for if the "
             "primary is down [OPTIONAL]")
+        parser.add_option("-f", "--fallback", dest="backupLife", default=None,
+            help="the number of getworks when on the backup mining server "
+            "before retrying the primary server [OPTIONAL]")
         parser.add_option("-q", "--queuesize", dest="queuesize", type="int",
             default=1, help="how many work units to keep queued at all times")
         parser.add_option("-a", "--avgsamples", dest="avgsamples", type="int",

Did I help you? Tiny Donations always welcome : 15Zk7DoFYJ7hESpZzmix1WLkomTMGW81c2
The World's Betting Exchange

Bet with play money. Win real Bitcoin. 5BTC Prize Fund for World Cup 2018.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1529695231
Hero Member
*
Offline Offline

Posts: 1529695231

View Profile Personal Message (Offline)

Ignore
1529695231
Reply with quote  #2

1529695231
Report to moderator
1529695231
Hero Member
*
Offline Offline

Posts: 1529695231

View Profile Personal Message (Offline)

Ignore
1529695231
Reply with quote  #2

1529695231
Report to moderator
1529695231
Hero Member
*
Offline Offline

Posts: 1529695231

View Profile Personal Message (Offline)

Ignore
1529695231
Reply with quote  #2

1529695231
Report to moderator
legolouman
Hero Member
*****
Offline Offline

Activity: 504
Merit: 500


Decent Programmer to boot!


View Profile
August 19, 2011, 07:15:32 PM
 #2

That's really neat. I only mine one pool at a time, due to consumption and noobness though. I also didn't know that Phoenix was written in Python.

If you love me, you'd give me a Satoshi!
BTC - 1MSzGKh5znbrcEF2qTrtrWBm4ydH5eT49f
LTC - LYeJrmYQQvt6gRQxrDz66XTwtkdodx9udz
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!