diff options
author | Linus Nordberg <linus@nordu.net> | 2015-09-24 18:20:18 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2015-09-24 18:20:18 +0200 |
commit | 02ab9ba3b43d7d42323db2effd787a0dce64e378 (patch) | |
tree | 1fe95b02a917421d661f9244303595a9dde6ae3d /tools | |
parent | 77475e45b7d1b64bbf0d1193fc1faa1eabfe5b17 (diff) |
Fix backup-quorum-size and use it.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/merge_sth.py | 13 |
1 files changed, 10 insertions, 3 deletions
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", \ |