Skip to content

Commit

Permalink
made all cache files be saved in data/
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Dec 8, 2011
1 parent 50f3c57 commit ef896fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
*.pyc
*.dat
*.iml
*.log
*_shares.*
.idea
/data/
*~
litecoin_scrypt/build/*
16 changes: 0 additions & 16 deletions dump_addrs.py

This file was deleted.

16 changes: 10 additions & 6 deletions p2pool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_payout_script2(bitcoind, net):
defer.returnValue(bitcoin_data.pubkey_to_script2(pubkey))

@defer.inlineCallbacks
def main(args, net):
def main(args, net, datadir_path):
try:
print 'p2pool (version %s)' % (p2pool.__version__,)
print
Expand Down Expand Up @@ -97,7 +97,7 @@ def main(args, net):

tracker = p2pool_data.OkayTracker(net)
shared_share_hashes = set()
ss = p2pool_data.ShareStore(os.path.join(os.path.dirname(sys.argv[0]), net.NAME + '_shares.'), net)
ss = p2pool_data.ShareStore(os.path.join(datadir_path, 'shares.'), net)
known_verified = set()
print "Loading shares..."
for i, (mode, contents) in enumerate(ss.get_shares()):
Expand Down Expand Up @@ -315,12 +315,12 @@ def parse(x):

addrs = {}
try:
addrs = dict(eval(x) for x in open(os.path.join(os.path.dirname(sys.argv[0]), net.NAME + '_addrs.txt')))
addrs = dict(eval(x) for x in open(os.path.join(datadir_path, 'addrs.txt')))
except:
print "error reading addrs"

def save_addrs():
open(os.path.join(os.path.dirname(sys.argv[0]), net.NAME + '_addrs.txt'), 'w').writelines(repr(x) + '\n' for x in addrs.iteritems())
open(os.path.join(datadir_path, 'addrs.txt'), 'w').writelines(repr(x) + '\n' for x in addrs.iteritems())
task.LoopingCall(save_addrs).start(60)

p2p_node = p2p.Node(
Expand Down Expand Up @@ -763,8 +763,12 @@ def convert_arg_line_to_args(self, arg_line):

net = networks.nets[args.net_name + ('_testnet' if args.testnet else '')]

datadir_path = os.path.join(os.path.dirname(sys.argv[0]), 'data', net.NAME)
if not os.path.exists(datadir_path):
os.makedirs(datadir_path)

if args.logfile is None:
args.logfile = os.path.join(os.path.dirname(sys.argv[0]), net.NAME + '.log')
args.logfile = os.path.join(datadir_path, 'log')

class LogFile(object):
def __init__(self, filename):
Expand Down Expand Up @@ -849,5 +853,5 @@ def sigusr1(signum, frame):
if (args.merged_url is None) ^ (args.merged_userpass is None):
parser.error('must specify --merged-url and --merged-userpass')

reactor.callWhenRunning(main, args, net)
reactor.callWhenRunning(main, args, net, datadir_path)
reactor.run()

0 comments on commit ef896fc

Please sign in to comment.