Bitcoin Forum
April 27, 2024, 08:07:49 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Example coinbaser script: proportional payout  (Read 1768 times)
Luke-Jr (OP)
Legendary
*
Offline Offline

Activity: 2576
Merit: 1186



View Profile
April 06, 2012, 04:00:23 PM
 #1

For a while, there has been one key component of Eligius that isn't open source: the coinbaser script. The reason for this is mainly due to the absurd ugliness it has become over time, and I hope to one day rewrite it in a clean way.

In the meantime, I stumbled upon a copy of the original coinbaser, before it got so messy. This was from when Eligius was a proportional pool, so I'm not sure how useful it is, but I thought it'd be good to publish it anyway...

Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import jsonrpc
import sqlite3

access = jsonrpc.ServiceProxy('http://bitcoinrpc:password@127.0.0.1:8332')
gs = access.listtransactions('*', 5)
gs = filter(lambda txn: txn['category'] in ('immature', 'generate'), gs)
gs = gs[-2:]

available = 50e8
distribution = {}

def distribute(addr, amount):
global available, distribution
if amount < 1:
return
available -= amount
if addr in distribution:
    amount += distribution[addr]
distribution[addr] = amount

# Make sure there's some leftover, so it shows up on listtransactions next time ;)
available -= 1

# Fee for running the pool: 1 base unit for every second :P
distribute('1CT1Wbu5kkQArCkWjHnzKyx6YaPCiFTJdB', gs[1]['time'] - gs[0]['time'])

sql = sqlite3.connect('/home/bitcoinpool/pool/data.sqlite')
sqlc = sql.cursor()
sqlc.execute('select count(username), username from shares where time > ?', (gs[1]['time'],))
shares = sqlc.fetchall()
sqlc.close()
del sqlc
sql.close()
del sql

total_available = available
total_shares = sum(map(lambda share: share[0], shares))
for share_count, share_addr in shares:
if not access.validateaddress(share_addr)['isvalid']:
continue
amount = total_available * share_count // total_shares
distribute(share_addr, amount)

print(len(distribution))
for addr, amount in distribution.iteritems():
print(amount)
print(addr)

1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
1714248469
Hero Member
*
Offline Offline

Posts: 1714248469

View Profile Personal Message (Offline)

Ignore
1714248469
Reply with quote  #2

1714248469
Report to moderator
martychubbs
Hero Member
*****
Offline Offline

Activity: 742
Merit: 503


View Profile
December 19, 2012, 07:13:56 PM
 #2

will this work for eloipool?  Huh Huh  Kiss


              ▄▄▄▄▄▄▄▄
          ▄▄████████████▄▄
       ▄████████████████████▄
     ▄██████████████▀█████████▄
   ▄███████████████   ██████████▄
  ▐█████████████████   ██████████▌
 ▐█████████████████▀    ██████████▌
 ███████████████▀        ██████████
▐████████████▀     ▄███   █████████▌
████████████    ▄████▀██▄███████████
██████████▀██▄████▀    █████████████
█████████   ███▀     ▄██████████████
▐█████████        ▄████████████████▌
 ██████████    ▄███████████████████
 ▐██████████   ███████████████████▌
  ▐██████████   █████████████████▌
   ▀██████████▄█████████████████▀
     ▀████████████████████████▀
       ▀████████████████████▀
          ▀▀████████████▀▀
              ▀▀▀▀▀▀▀▀




     █
    ██
   ████
  ██▌███
 ▐██▌███▌
 ███ ██▀▌
 ▀██ █▄██
 █▄█ ███▀
 ▀██ ██▄█
 █▄█ ███▌
  ██▌███
  ▐█▌██
   ▐█▌
    █
    █
     ▀
 




░░██████
░░██████
░░██████

░░░░░░░░░░░██████
░░░░░░░░░░░██████
░░░░░░░░░░░██████

██████
██████
██████

░░░░░░░░░░░░░░░░░░░██████
░░░░░░░░░░░░░░░░░░░██████
░░░░░░░░░░░░░░░░░░░██████
 







        ▄▄██████▄▄
       ▐██▀    ▀██▌
       ██        ██
       ██        ██
       ██        ██
      ██████████████
      █████  ███████     ██ 
  ██  █  ████████  █ ██   
      ███████  █████    ██   
      ██████████████
 








▄██▄
▀██▀         ▄██▄
             ▀██▀

       ▄██▄
       ▀██▀

           ▄██▄
  ▄██▄     ▀██▀
  ▀██▀
 


           ▄▄█▄▄   ▄
█▄        ████████▀▄
███      █████████▀
▐███▄    ████████▌
▄▄█████▄▄▄███████▌
  ▀█████████████
  ▄▄██████████▀
    ▄████████▀
▀▀████████▀
    ▀▀▀
 

    ▄█▀▀ ▄▄▄▄▄▄ ▀▀█▄
   ▐█▄████████████▄█▌
  ▐██████████████████▌
  █████▀▀▀████▀▀▀█████
 █████     ██     █████
▐██████▄▄▄████▄▄▄██████▌
 ████▄▀▀▀██████▀▀▀▄████
  ▀▀████        ████▀▀
      ▀▀        ▀▀
 

         █▀▀▄▄▄█▄
         █    ▀█▀
       ▄▄█▄▄
▄██▄▄████████▄▄██▄
█████▀▀████▀▀█████
 ███▄  ▄██▄  ▄███
  ▀████▀██▀████▀
    ▀███▄▄███▀
       ▀▀▀▀

██ ██ ██ ██

   ██ ██ ██

      ██ ██

      ██ ██
   
Homepage

      ██ ██

      ██ ██

   ██ ██ ██

██ ██ ██ ██
   
White Paper
Luke-Jr (OP)
Legendary
*
Offline Offline

Activity: 2576
Merit: 1186



View Profile
December 19, 2012, 08:19:33 PM
 #3

will this work for eloipool?  Huh Huh  Kiss
It should, if you setup the SQL schemas and such correctly.

martychubbs
Hero Member
*****
Offline Offline

Activity: 742
Merit: 503


View Profile
January 03, 2013, 04:25:41 PM
 #4

will this work for eloipool?  Huh Huh  Kiss
It should, if you setup the SQL schemas and such correctly.

thanks for the update!


              ▄▄▄▄▄▄▄▄
          ▄▄████████████▄▄
       ▄████████████████████▄
     ▄██████████████▀█████████▄
   ▄███████████████   ██████████▄
  ▐█████████████████   ██████████▌
 ▐█████████████████▀    ██████████▌
 ███████████████▀        ██████████
▐████████████▀     ▄███   █████████▌
████████████    ▄████▀██▄███████████
██████████▀██▄████▀    █████████████
█████████   ███▀     ▄██████████████
▐█████████        ▄████████████████▌
 ██████████    ▄███████████████████
 ▐██████████   ███████████████████▌
  ▐██████████   █████████████████▌
   ▀██████████▄█████████████████▀
     ▀████████████████████████▀
       ▀████████████████████▀
          ▀▀████████████▀▀
              ▀▀▀▀▀▀▀▀




     █
    ██
   ████
  ██▌███
 ▐██▌███▌
 ███ ██▀▌
 ▀██ █▄██
 █▄█ ███▀
 ▀██ ██▄█
 █▄█ ███▌
  ██▌███
  ▐█▌██
   ▐█▌
    █
    █
     ▀
 




░░██████
░░██████
░░██████

░░░░░░░░░░░██████
░░░░░░░░░░░██████
░░░░░░░░░░░██████

██████
██████
██████

░░░░░░░░░░░░░░░░░░░██████
░░░░░░░░░░░░░░░░░░░██████
░░░░░░░░░░░░░░░░░░░██████
 







        ▄▄██████▄▄
       ▐██▀    ▀██▌
       ██        ██
       ██        ██
       ██        ██
      ██████████████
      █████  ███████     ██ 
  ██  █  ████████  █ ██   
      ███████  █████    ██   
      ██████████████
 








▄██▄
▀██▀         ▄██▄
             ▀██▀

       ▄██▄
       ▀██▀

           ▄██▄
  ▄██▄     ▀██▀
  ▀██▀
 


           ▄▄█▄▄   ▄
█▄        ████████▀▄
███      █████████▀
▐███▄    ████████▌
▄▄█████▄▄▄███████▌
  ▀█████████████
  ▄▄██████████▀
    ▄████████▀
▀▀████████▀
    ▀▀▀
 

    ▄█▀▀ ▄▄▄▄▄▄ ▀▀█▄
   ▐█▄████████████▄█▌
  ▐██████████████████▌
  █████▀▀▀████▀▀▀█████
 █████     ██     █████
▐██████▄▄▄████▄▄▄██████▌
 ████▄▀▀▀██████▀▀▀▄████
  ▀▀████        ████▀▀
      ▀▀        ▀▀
 

         █▀▀▄▄▄█▄
         █    ▀█▀
       ▄▄█▄▄
▄██▄▄████████▄▄██▄
█████▀▀████▀▀█████
 ███▄  ▄██▄  ▄███
  ▀████▀██▀████▀
    ▀███▄▄███▀
       ▀▀▀▀

██ ██ ██ ██

   ██ ██ ██

      ██ ██

      ██ ██
   
Homepage

      ██ ██

      ██ ██

   ██ ██ ██

██ ██ ██ ██
   
White Paper
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!