diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/gitian-descriptors/boost-win.yml | 2 | ||||
-rw-r--r-- | contrib/gitian-descriptors/deps-win.yml | 4 | ||||
-rw-r--r-- | contrib/gitian-descriptors/gitian-win.yml | 4 | ||||
-rw-r--r-- | contrib/gitian-descriptors/protobuf-win.yml | 2 | ||||
-rw-r--r-- | contrib/gitian-descriptors/qt-linux.yml | 4 | ||||
-rw-r--r-- | contrib/gitian-descriptors/qt-win.yml | 2 | ||||
-rwxr-xr-x | contrib/linearize/linearize-hashes.py | 71 |
7 files changed, 48 insertions, 41 deletions
diff --git a/contrib/gitian-descriptors/boost-win.yml b/contrib/gitian-descriptors/boost-win.yml index db5d6bab1d..347952e3a6 100644 --- a/contrib/gitian-descriptors/boost-win.yml +++ b/contrib/gitian-descriptors/boost-win.yml @@ -29,7 +29,7 @@ script: | # INSTALLPREFIX=$HOME/staging${BITS} BUILDDIR=$HOME/build${BITS} - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then HOST=i686-w64-mingw32 else HOST=x86_64-w64-mingw32 diff --git a/contrib/gitian-descriptors/deps-win.yml b/contrib/gitian-descriptors/deps-win.yml index fabc2949eb..fe02950ef9 100644 --- a/contrib/gitian-descriptors/deps-win.yml +++ b/contrib/gitian-descriptors/deps-win.yml @@ -39,7 +39,7 @@ script: | # INSTALLPREFIX=$HOME/staging${BITS} BUILDDIR=$HOME/build${BITS} - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then HOST=i686-w64-mingw32 else HOST=x86_64-w64-mingw32 @@ -50,7 +50,7 @@ script: | # tar xzf $INDIR/openssl-1.0.1h.tar.gz cd openssl-1.0.1h - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then OPENSSL_TGT=mingw else OPENSSL_TGT=mingw64 diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index 245f15ccab..b2795c5376 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -50,7 +50,7 @@ script: | STAGING=$HOME/staging${BITS} BUILDDIR=$HOME/build${BITS} BINDIR=$OUTDIR/$BITS - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then HOST=i686-w64-mingw32 else HOST=x86_64-w64-mingw32 @@ -63,7 +63,7 @@ script: | unzip $INDIR/boost-win${BITS}-1.55.0-gitian-r6.zip unzip $INDIR/bitcoin-deps-win${BITS}-gitian-r13.zip unzip $INDIR/protobuf-win${BITS}-2.5.0-gitian-r4.zip - if [ "$NEEDDIST" == "1" ]; then + if [ "x$NEEDDIST" = "x1" ]; then # Make source code archive which is architecture independent so it only needs to be done once cd $HOME/build/bitcoin ./autogen.sh diff --git a/contrib/gitian-descriptors/protobuf-win.yml b/contrib/gitian-descriptors/protobuf-win.yml index d2fdcaa7f2..1b7af08843 100644 --- a/contrib/gitian-descriptors/protobuf-win.yml +++ b/contrib/gitian-descriptors/protobuf-win.yml @@ -26,7 +26,7 @@ script: | # INSTALLPREFIX=$HOME/staging${BITS} BUILDDIR=$HOME/build${BITS} - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then HOST=i686-w64-mingw32 else HOST=x86_64-w64-mingw32 diff --git a/contrib/gitian-descriptors/qt-linux.yml b/contrib/gitian-descriptors/qt-linux.yml index b163b4bb8c..fd86b4df1d 100644 --- a/contrib/gitian-descriptors/qt-linux.yml +++ b/contrib/gitian-descriptors/qt-linux.yml @@ -18,7 +18,7 @@ files: script: | export FAKETIME=$REFERENCE_DATETIME export TZ=UTC - if [ "$GBUILD_BITS" == "32" ]; then + if [ "x$GBUILD_BITS" = "x32" ]; then ARCH='i386-linux-gnu' else ARCH='x86_64-linux-gnu' @@ -74,7 +74,7 @@ script: | #endif ' > $QCONFIG - if [ "$GBUILD_BITS" == "32" ]; then + if [ "x$GBUILD_BITS" = "x32" ]; then echo ' /* Machine byte-order */ #define Q_BIG_ENDIAN 4321 diff --git a/contrib/gitian-descriptors/qt-win.yml b/contrib/gitian-descriptors/qt-win.yml index 7000c70051..57bc4c3180 100644 --- a/contrib/gitian-descriptors/qt-win.yml +++ b/contrib/gitian-descriptors/qt-win.yml @@ -38,7 +38,7 @@ script: | INSTALLPREFIX=$HOME/staging${BITS} BUILDDIR=$HOME/build${BITS} DEPSDIR=$HOME/deps${BITS} - if [ "$BITS" == "32" ]; then + if [ "x$BITS" = "x32" ]; then HOST=i686-w64-mingw32 else HOST=x86_64-w64-mingw32 diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py index 791b71bc33..dc7f654049 100755 --- a/contrib/linearize/linearize-hashes.py +++ b/contrib/linearize/linearize-hashes.py @@ -2,11 +2,12 @@ # # linearize-hashes.py: List blocks in a linear, no-fork version of the chain. # -# Copyright (c) 2013 The Bitcoin developers +# Copyright (c) 2013-2014 The Bitcoin developers # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # +from __future__ import print_function import json import struct import re @@ -17,59 +18,65 @@ import sys settings = {} class BitcoinRPC: - OBJID = 1 - def __init__(self, host, port, username, password): authpair = "%s:%s" % (username, password) self.authhdr = "Basic %s" % (base64.b64encode(authpair)) self.conn = httplib.HTTPConnection(host, port, False, 30) - def rpc(self, method, params=None): - self.OBJID += 1 - obj = { 'version' : '1.1', - 'method' : method, - 'id' : self.OBJID } - if params is None: - obj['params'] = [] - else: - obj['params'] = params + + def execute(self, obj): self.conn.request('POST', '/', json.dumps(obj), { 'Authorization' : self.authhdr, 'Content-type' : 'application/json' }) resp = self.conn.getresponse() if resp is None: - print "JSON-RPC: no response" + print("JSON-RPC: no response", file=sys.stderr) return None body = resp.read() resp_obj = json.loads(body) - if resp_obj is None: - print "JSON-RPC: cannot JSON-decode body" - return None - if 'error' in resp_obj and resp_obj['error'] != None: - return resp_obj['error'] - if 'result' not in resp_obj: - print "JSON-RPC: no result in object" - return None + return resp_obj - return resp_obj['result'] - def getblock(self, hash, verbose=True): - return self.rpc('getblock', [hash, verbose]) - def getblockhash(self, index): - return self.rpc('getblockhash', [index]) + @staticmethod + def build_request(idx, method, params): + obj = { 'version' : '1.1', + 'method' : method, + 'id' : idx } + if params is None: + obj['params'] = [] + else: + obj['params'] = params + return obj + + @staticmethod + def response_is_error(resp_obj): + return 'error' in resp_obj and resp_obj['error'] is not None -def get_block_hashes(settings): +def get_block_hashes(settings, max_blocks_per_call=10000): rpc = BitcoinRPC(settings['host'], settings['port'], settings['rpcuser'], settings['rpcpassword']) - for height in xrange(settings['min_height'], settings['max_height']+1): - hash = rpc.getblockhash(height) + height = settings['min_height'] + while height < settings['max_height']+1: + num_blocks = min(settings['max_height']+1-height, max_blocks_per_call) + batch = [] + for x in range(num_blocks): + batch.append(rpc.build_request(x, 'getblockhash', [height + x])) + + reply = rpc.execute(batch) + + for x,resp_obj in enumerate(reply): + if rpc.response_is_error(resp_obj): + print('JSON-RPC: error at height', height+x, ': ', resp_obj['error'], file=sys.stderr) + exit(1) + assert(resp_obj['id'] == x) # assume replies are in-sequence + print(resp_obj['result']) - print(hash) + height += num_blocks if __name__ == '__main__': if len(sys.argv) != 2: - print "Usage: linearize-hashes.py CONFIG-FILE" + print("Usage: linearize-hashes.py CONFIG-FILE") sys.exit(1) f = open(sys.argv[1]) @@ -95,7 +102,7 @@ if __name__ == '__main__': if 'max_height' not in settings: settings['max_height'] = 313000 if 'rpcuser' not in settings or 'rpcpassword' not in settings: - print "Missing username and/or password in cfg file" + print("Missing username and/or password in cfg file", file=stderr) sys.exit(1) settings['port'] = int(settings['port']) |