Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #mining sim for 'How to hop 9'
- D<-1200000;B<-50
- maxRounds<-100;hop1<-.25*D;hop2<-0.5*D;hop3<-D
- minerHashrate <-1; poolHashrate <-1000
- earnings<-matrix(0,maxRounds,8)
- totalRoundShares<-rgeom(maxRounds,1/D)+1
- for(i in 1:maxRounds){
- earnings[i,1]<-i
- earnings[i,2]<-totalRoundShares[i]
- earnings[i,3]<-earnings[i,4]<-earnings[i,5]<-minerHashrate/poolHashrate*B
- earnings[i,6]<-earnings[i,7]<-earnings[i,8]<-B/D*minerHashrate/poolHashrate*totalRoundShares[i]
- if(totalRoundShares[i]>hop1){earnings[i,3]<-minerHashrate/poolHashrate*hop1/totalRoundShares[i]*B;earnings[i,6]<-B/D*hop1*minerHashrate/poolHashrate}
- if(totalRoundShares[i]>hop2){earnings[i,4]<-minerHashrate/poolHashrate*hop2/totalRoundShares[i]*B;earnings[i,7]<-B/D*hop2*minerHashrate/poolHashrate}
- if(totalRoundShares[i]>hop3){earnings[i,5]<-minerHashrate/poolHashrate*hop3/totalRoundShares[i]*B;earnings[i,8]<-B/D*hop3*minerHashrate/poolHashrate}
- }
- x<-cumsum(earnings[,2])
- prop1<-cumsum(earnings[,3]);pps1<-cumsum(earnings[,6])
- prop2<-cumsum(earnings[,4]);pps2<-cumsum(earnings[,7])
- prop3<-cumsum(earnings[,5]);pps3<-cumsum(earnings[,8])
- ylim1<-max(max(prop1),max(pps1));ylim2<-max(max(prop2),max(pps2));ylim3<-max(max(prop3),max(pps3))
- png('miner-earning-2simulation%03d.png')
- plot(x,prop1,type='l',ylim=c(0,ylim1),col='red',lwd=2,axes=F,xlab='',ylab='')
- par(new=T)
- plot(x,pps1,type='l',ylim=c(0,ylim1),col='blue',lwd=2,axes=F,xlab='',ylab='')
- axis(1,at=x,labels=earnings[,1]);axis(2)
- title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for',hop1/D,'*D shares\n D=1200000'))
- legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
- plot(x,prop2,type='l',ylim=c(0,ylim2),col='red',lwd=2,axes=F,xlab='',ylab='')
- par(new=T)
- plot(x,pps2,type='l',ylim=c(0,ylim2),col='blue',lwd=2,axes=F,xlab='',ylab='')
- axis(1,at=x,labels=earnings[,1]);axis(2)
- title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for',hop2/D,'*D shares\n D=1200000'))
- legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
- plot(x,prop3,type='l',ylim=c(0,ylim3),col='red',lwd=2,axes=F,xlab='',ylab='')
- par(new=T)
- plot(x,pps3,type='l',ylim=c(0,ylim3),col='blue',lwd=2,axes=F,xlab='',ylab='')
- axis(1,at=x,labels=earnings[,1]);axis(2)
- title(xlab='Block number',ylab='Bitcoin earned',main=paste('Cumulative earned for D shares\n D=1200000'))
- legend('topleft',c('Proportional miner','PPS miner'),col=c('red','blue'),lty=1,lwd=2,bty='n')
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement