From 67e2935f90f89ecc93dc98c430148829ad3f2908 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Thu, 24 Sep 2015 18:20:18 +0200 Subject: Fix backup-quorum-size and use it. --- tools/merge_sth.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/merge_sth.py b/tools/merge_sth.py index 68b52a0..bd49c9f 100755 --- a/tools/merge_sth.py +++ b/tools/merge_sth.py @@ -8,7 +8,7 @@ import sys import json import urllib2 import time -from base64 import b64encode, b64decode +from base64 import b64encode from mergetools import parse_args, get_nfetched, hexencode, hexdecode, \ get_logorder, get_sth from certtools import create_ssl_context, get_public_key_from_file, \ @@ -26,13 +26,15 @@ def merge_sth(args, config, localconfig): mergedb = paths["mergedb"] sthfile = mergedb + "/sth" logorderfile = mergedb + "/logorder" + currentsizefile = mergedb + "/fetched" logpublickey = get_public_key_from_file(paths["logpublickey"]) - backupquorum = localconfig.get("backupquorum", 0) + backupquorum = config.get("backup-quorum-size", 0) assert backupquorum <= len(mergenodes) - 1 create_ssl_context(cafile=paths["https_cacertfile"]) timing = timing_point() - trees = [{'tree_size': 0, 'sha256_root_hash': ''}] + trees = [{'tree_size': get_nfetched(currentsizefile, logorderfile), + 'sha256_root_hash': ''}] for mergenode in mergenodes: if mergenode["name"] == config["primarymergenode"]: continue @@ -44,6 +46,11 @@ def merge_sth(args, config, localconfig): trees.append(tree) trees.sort(key=lambda e: e['tree_size'], reverse=True) print >>sys.stderr, "DEBUG: trees:", trees + + if backupquorum > len(trees) - 1: + print >>sys.stderr, "backup quorum > number of secondaries:", \ + backupquorum, ">", len(trees) - 1 + return tree_size = trees[backupquorum]['tree_size'] root_hash = hexdecode(trees[backupquorum]['sha256_root_hash']) print >>sys.stderr, "DEBUG: tree size candidate at backupquorum", \ -- cgit v1.1