summaryrefslogtreecommitdiff
path: root/tools/merge.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/merge.py')
-rwxr-xr-xtools/merge.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/merge.py b/tools/merge.py
index e007d7c..1cc75ef 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -54,6 +54,22 @@ def get_new_entries(baseurl):
print "ERROR: fetchnewentries", e.read()
sys.exit(1)
+def get_entry(baseurl, hash):
+ try:
+ params = urllib.urlencode({"hash":base64.b64encode(hash)})
+ result = urllib2.urlopen(baseurl + "ct/storage/getentry?" + params).read()
+ parsed_result = json.loads(result)
+ if parsed_result.get(u"result") == u"ok":
+ entries = parsed_result[u"entries"]
+ assert len(entries) == 1
+ assert base64.b64decode(entries[0]["hash"]) == hash
+ return base64.b64decode(entries[0]["entry"])
+ print "ERROR: getentry", parsed_result
+ sys.exit(1)
+ except urllib2.HTTPError, e:
+ print "ERROR: getentry", e.read()
+ sys.exit(1)
+
def get_curpos(baseurl):
try:
result = urllib2.urlopen(baseurl + "ct/frontend/currentposition").read()
@@ -135,9 +151,9 @@ new_entries = [entry for storagenode in storagenodes for entry in get_new_entrie
print "adding entries"
added_entries = 0
for new_entry in new_entries:
- hash = base64.b64decode(new_entry["hash"])
- entry = base64.b64decode(new_entry["entry"])
+ hash = base64.b64decode(new_entry)
if hash not in certsinlog:
+ entry = get_entry(storagenode, hash)
write_chain(hash, entry)
add_to_logorder(hash)
logorder.append(hash)