Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion msc_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ def main():
parser = OptionParser("usage: %prog [options]")
parser.add_option("-d", "--debug", action="store_true",dest='debug_mode', default=False,
help="turn debug mode on")
parser.add_option( "-r", "--repository-path", dest='repository_path', default="~/mastercoin-tools",
help="Specify the location of the mastercoin-tools repository (defaults to ~/mastercoin-tools" )

(options, args) = parser.parse_args()
d=options.debug_mode

# zip all parsed data and put in downloads
archive_parsed_data()
archive_parsed_data( options.repository_path )

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion msc_cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ python msc_validate.py 2>&1 > $VALIDATE_LOG
cp tx/* www/tx/
cp addr/* www/addr/
cp general/* www/general/
cp bids/* www/bids/
cp offers/* www/offers/
mkdir -p www/mastercoin_verify/addresses/
cp mastercoin_verify/addresses/* www/mastercoin_verify/addresses/
mkdir -p www/mastercoin_verify/transactions/
Expand Down
6 changes: 4 additions & 2 deletions msc_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def parse():
help="start the parsing at a specific block height (default is last)")
parser.add_option("-a", "--archive-parsed-data", action="store_true",dest='archive', default=False,
help="archive the parsed data of tx addr and general for others to download")
parser.add_option( "-r", "--repository-path", dest='repository_path', default="~/mastercoin-tools",
help="Specify the location of the mastercoin-tools repository (defaults to ~/mastercoin-tools" )

(options, args) = parser.parse_args()
d=options.debug_mode
Expand Down Expand Up @@ -246,11 +248,11 @@ def parse():
if single_tx == None and block != None:
msc_globals.last_block=block

rev=get_revision_dict(last_block)
rev=get_revision_dict( last_block, options.repository_path )
atomic_json_dump(rev, 'www/revision.json', add_brackets=False)

if archive:
archive_parsed_data()
archive_parsed_data( options.repository_path )

if __name__ == "__main__":
parse()
8 changes: 4 additions & 4 deletions msc_utils_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ def get_git_details(directory="~/mastercoin-tools"):
return(head_commit.hexsha,timestamp)

def archive_repo(directory="~/mastercoin-tools"):
(commit_hexsha, timestamp)=get_git_details()
(commit_hexsha, timestamp)=get_git_details( directory )
assert repo.bare == False
archive_name='www/downloads/mastercoin-tools-src-'+timestamp+'-'+commit_hexsha[:8]+'-'+timestamp+'.tar'
repo = git.Repo(directory)
repo.archive(open(archive_name,'w'))

def archive_parsed_data(directory="~/mastercoin-tools"):
(commit_hexsha, timestamp)=get_git_details()
(commit_hexsha, timestamp)=get_git_details( directory )
archive_name='www/downloads/mastercoin-tools-parse-snapshot-'+timestamp+'-'+commit_hexsha[:8]+'.tar.gz'
path_to_archive='www/revision.json www/tx www/addr www/general/'
out, err = run_command("tar cz "+path_to_archive+" -f "+archive_name)
Expand All @@ -123,9 +123,9 @@ def get_now():
def get_today():
return format_time_from_struct(time.gmtime(), True)

def get_revision_dict(last_block):
def get_revision_dict( last_block, directory="~/mastercoin-tools" ):
rev={}
git_details=get_git_details()
git_details=get_git_details( directory )
hexsha=git_details[0]
commit_time=git_details[1]
rev['commit_hexsha']=hexsha
Expand Down
28 changes: 14 additions & 14 deletions msc_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
coins_reverse_short_name_dict=dict((v,k) for k, v in coins_short_name_dict.iteritems())

# create modified tx dict which would be used to modify tx files
bids_dict={}
offers_dict={}

# global last block on the net
last_height=get_last_height()
Expand Down Expand Up @@ -330,11 +330,11 @@ def mark_tx_invalid(tx_hash, reason):
update_tx_dict(tx_hash, invalid=(True,reason), color='bgc-invalid')

# add another sell tx to the modified dict
def add_bids(key, t):
if bids_dict.has_key(key):
bids_dict[key].append(t)
def add_offers(key, t):
if offers_dict.has_key(key):
offers_dict[key].append(t)
else:
bids_dict[key]=[t]
offers_dict[key]=[t]


# write back to fs all tx which got modified
Expand All @@ -347,11 +347,11 @@ def write_back_modified_tx():
# save back to filesystem
atomic_json_dump(tx_dict[k], 'tx/'+k+'.json', add_brackets=False)

# create bids json
def update_bids():
for tx_hash in bids_dict.keys():
# write updated bids
atomic_json_dump(bids_dict[tx_hash], 'bids/bids-'+tx_hash+'.json', add_brackets=False)
# create offers json
def update_offers():
for tx_hash in offers_dict.keys():
# write updated offers
atomic_json_dump(offers_dict[tx_hash], 'offers/offers-'+tx_hash+'.json', add_brackets=False)

def update_bitcoin_balances():
chunk=100
Expand Down Expand Up @@ -698,9 +698,9 @@ def check_mastercoin_transaction(t, index=-1):
update_tx_dict(sell_offer_tx['tx_hash'], color='bgc-accepted', icon_text='Sell offer accepted')
else:
mark_tx_invalid(t['tx_hash'],'non positive spot accept')
# add to current bids (which appear on seller tx)
# add to current offers (which appear on seller tx)
key=sell_offer_tx['tx_hash']
add_bids(key, t)
add_offers(key, t)
return True
else:
info('unknown tx type: '+t['tx_type_str']+' in '+tx_hash)
Expand Down Expand Up @@ -778,8 +778,8 @@ def validate():
except OSError:
error('error on tx '+t['tx_hash'])

# create json for bids
update_bids()
# create json for offers
update_offers()

# update changed tx
write_back_modified_tx()
Expand Down