diff --git a/msc_archive.py b/msc_archive.py index 4896967..becc6f9 100644 --- a/msc_archive.py +++ b/msc_archive.py @@ -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() diff --git a/msc_cron.sh b/msc_cron.sh index 0eddd70..23c28b0 100644 --- a/msc_cron.sh +++ b/msc_cron.sh @@ -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/ diff --git a/msc_parse.py b/msc_parse.py index 3336f03..44011a1 100644 --- a/msc_parse.py +++ b/msc_parse.py @@ -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 @@ -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() diff --git a/msc_utils_general.py b/msc_utils_general.py index c8c6643..aac2664 100644 --- a/msc_utils_general.py +++ b/msc_utils_general.py @@ -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) @@ -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 diff --git a/msc_validate.py b/msc_validate.py index 0f70c4a..aef77ec 100644 --- a/msc_validate.py +++ b/msc_validate.py @@ -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() @@ -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 @@ -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 @@ -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) @@ -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()