Skip to content

Commit

Permalink
Building Challenge Class
Browse files Browse the repository at this point in the history
  • Loading branch information
super3 committed May 31, 2015
1 parent ec6ab9f commit 0490806
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
16 changes: 16 additions & 0 deletions dataserv/Challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import random

class Challenge:
def seed_list(self, height):
"""Generate a list of seeds for challenges based on the Bitcoin address."""
seeds = []
last_seed = sha256(self.btc_addr)
for i in range(height+1):
seeds.append(last_seed)
last_seed =sha256(last_seed)
return seeds

def gen_challenge(self):
"""Generate a random challenge for the Farmer."""
iter_seed = random.randrange(0, len(app.config['SEED_HEIGHT']))
seeds = self.seed_list(app.config['SEED_HEIGHT'])
14 changes: 1 addition & 13 deletions dataserv/Farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///dataserv.db'
app.config['SEED_HEIGHT'] = 100
db = SQLAlchemy(app)


Expand Down Expand Up @@ -76,16 +77,3 @@ def ping(self):
"""
self = Farmer.query.filter_by(btc_addr=self.btc_addr)
self.update(dict(last_seen=datetime.utcnow()))

def seed_list(self, height):
"""Generate a list of seeds for challenges based on the Bitcoin address."""
seeds = []
last_seed = sha256(self.btc_addr)
for i in range(height):
seeds.append(last_seed)
last_seed =sha256(last_seed)
return seeds

def gen_challenge(self):
"""Generate a random challenge for the Farmer."""
pass

0 comments on commit 0490806

Please sign in to comment.