From e8399cb48546d342b508f2a1e946824eac9c07e1 Mon Sep 17 00:00:00 2001 From: Jakub Matys Date: Fri, 23 Mar 2018 13:26:24 +0100 Subject: [PATCH] Added ability of getBlockHeader control to send either height or hash --- server/static/test.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/static/test.html b/server/static/test.html index 4eb7a4ba..502c9028 100644 --- a/server/static/test.html +++ b/server/static/test.html @@ -102,17 +102,22 @@ } function getBlockHeader() { - var height = document.getElementById('getBlockHeaderHeight').value; - lookupBlockHash(parseInt(height), function (result) { + var param = document.getElementById('getBlockHeaderParam').value; + lookupBlockHash(isHash(param) ? param : parseInt(param), function (result) { console.log('getBlockHeader sent successfully'); console.log(result); document.getElementById('getBlockHeaderResult').innerText = JSON.stringify(result).replace(/,/g, ", "); }); } - function lookupBlockHash(height, f) { + function isHash(str) { + var re = /[0-9A-Fa-f]{64}/g; + return re.test(str); + } + + function lookupBlockHash(heightOrHash, f) { const method = 'getBlockHeader'; - const params = [height]; + const params = [heightOrHash]; return socket.send({ method, params }, f); } @@ -277,7 +282,7 @@
- +