Post
Topic
Board Altcoin Discussion
Re: Does a high pool difficulty lower anyone's profits?
by
mueslo
on 23/08/2013, 16:57:47 UTC
[...]

Here's the code for per pool-found-block/proportional reward. There's no change (as is to be expected, all proportional reward does is increase variance (as long as there's no pool hopping)):

Code:
import numpy.random as rnd
import numpy as np

class worker():
    sharetime = None #time the next share is found by the worker
    def __init__(self,avgsharetime):
        self.avgsharetime = avgsharetime
        self.hashrate = 60/avgsharetime
        self.shares = 0
        self.roundshares = 0
        self.income = 0.
        self.generateShareTime(0.0)
    
    def generateShareTime(self, currenttime):
        self.sharetime = currenttime + rnd.exponential(scale=self.avgsharetime)
    
    def foundShare(self, currenttime):
        self.shares+=1
        self.roundshares+=1
        self.generateShareTime(currenttime)


class pool():
    t = 0. #time elapsed
    blocktime = None #time the next block is found (by the network)
    pblock = 0.02 #probability that a share solves the block
    totalroundshares = 0 #number of total shares solved for this block round
    workers = [] #list of workers in the pool
    def __init__(self,avgnetworkblocktime=10.,workers=[],):
        self.avgnetworkblocktime = avgnetworkblocktime
        self.generateNetworkBlockTime(0.0)
        self.workers=workers
        
    def start(self,duration=100.):
        while self.t            nextworker = self.workers[np.argmin([w.sharetime for w in self.workers])]
            nextsharetime = nextworker.sharetime            
            
            if self.blocktime                self.newNetworkBlock()
            
            else:                            #worker found a share
                self.t = nextworker.sharetime
                self.totalroundshares+=1
                nextworker.foundShare(self.t)

                
                if rnd.uniform(0,1)                    self.newPoolBlock()


        
    def generateNetworkBlockTime(self,currenttime):
        self.blocktime = currenttime + rnd.exponential(scale=self.avgnetworkblocktime)
        
    def distributeRewards(self):
        print "Shares: [",
        for w in self.workers:
            print w.roundshares,
            w.income += float(w.roundshares)/float(self.totalroundshares)
            w.roundshares = 0
        self.totalroundshares = 0
        print "]\n"
        
    def newPoolBlock(self):
        print "\nnew pool block t=",self.t,"-> Payout!"
        self.distributeRewards()
        
        self.blocktime = self.t
        self.newNetworkBlock(echo=False)
        
    def newNetworkBlock(self,echo=True):
        self.t=self.blocktime
        if echo: print "new network block t=",self.t
        for w in self.workers: #if you disable these, nothing changes in the outcome
            w.generateShareTime(self.t)
        
        self.generateNetworkBlockTime(self.t)
        


slowworker = worker(avgsharetime=30)
mediumworker = worker(avgsharetime=10)
fastworker = worker(avgsharetime=3)


pool1 = pool(workers=[fastworker, mediumworker, slowworker],avgnetworkblocktime=10.)
pool1.start(duration=100000.)

print fastworker.shares
print slowworker.shares
    
print "Slow worker has: " + str((float(slowworker.hashrate) / float(fastworker.hashrate)) * 100) + ' percent of the hash power of fast worker'
print "Slow worker has: " + str((float(slowworker.income) / float(fastworker.income)) * 100) + ' percent of the profit of fast worker'
print "Slow worker has: " + str((float(slowworker.shares) / float(fastworker.shares)) * 100) + ' percent of the total shares of fast worker'

And some example outputs:
Slow worker has: 10.0 percent of the hash power of fast worker
Slow worker has: 10.0643834344 percent of the profit of fast worker
Slow worker has: 10.2436090226 percent of the total shares of fast worker

Slow worker has: 10.0 percent of the hash power of fast worker
Slow worker has: 9.89355458187 percent of the profit of fast worker
Slow worker has: 9.99728580476 percent of the total shares of fast worker

Slow worker has: 10.0 percent of the hash power of fast worker
Slow worker has: 10.2071470481 percent of the profit of fast worker
Slow worker has: 10.1000090098 percent of the total shares of fast worker

Slow worker has: 10.0 percent of the hash power of fast worker
Slow worker has: 9.78155423167 percent of the profit of fast worker
Slow worker has: 10.1675711134 percent of the total shares of fast worker

Slow worker has: 10.0 percent of the hash power of fast worker
Slow worker has: 9.84810455803 percent of the profit of fast worker
Slow worker has: 9.8902409926 percent of the total shares of fast worker

example found blocks