mirror of
https://github.com/fluencelabs/tendermint-demo
synced 2025-03-14 23:30:49 +00:00
Updated scripts
This commit is contained in:
parent
77b25c6630
commit
216ca72f19
@ -1,10 +0,0 @@
|
|||||||
python query.py localhost:46257 put a/b=10
|
|
||||||
python query.py localhost:46257 put "a/c=copy(a/b)"
|
|
||||||
python query.py localhost:46257 put "a/d=increment(a/c)"
|
|
||||||
python query.py localhost:46257 put "a/d=increment(a/c)###again"
|
|
||||||
python query.py localhost:46257 put "a/e=sum(a/c,a/d)"
|
|
||||||
python query.py localhost:46257 put "a/f=factorial(a/b)"
|
|
||||||
python query.py localhost:46257 put "c/asum=hiersum(a)"
|
|
||||||
python query.py localhost:46257 get a/e
|
|
||||||
python query.py localhost:46257 put "0-200:b/@1/@0=1"
|
|
||||||
python query.py localhost:46257 put "c/bsum=hiersum(b)"
|
|
@ -20,7 +20,7 @@ for height in range(min_height, max_height + 1):
|
|||||||
bulk_data = (read_json(tmaddress + "/blockchain?minHeight=%d&maxHeight=%d" % (height, last_fetched_height)))["result"]["block_metas"]
|
bulk_data = (read_json(tmaddress + "/blockchain?minHeight=%d&maxHeight=%d" % (height, last_fetched_height)))["result"]["block_metas"]
|
||||||
|
|
||||||
data = bulk_data[last_fetched_height - height]["header"]
|
data = bulk_data[last_fetched_height - height]["header"]
|
||||||
|
|
||||||
num_txs = data["num_txs"]
|
num_txs = data["num_txs"]
|
||||||
total_txs = data["total_txs"]
|
total_txs = data["total_txs"]
|
||||||
app_hash = data["app_hash"]
|
app_hash = data["app_hash"]
|
||||||
|
28
cli/query.py
28
cli/query.py
@ -3,11 +3,10 @@ import sys, urllib, json, datetime, time, hashlib, sha3
|
|||||||
from common_parse_utils import read_json, get_sync_info, get_max_height
|
from common_parse_utils import read_json, get_sync_info, get_max_height
|
||||||
|
|
||||||
|
|
||||||
CMD_RUN = "run"
|
|
||||||
CMD_PUT_TX = "put"
|
CMD_PUT_TX = "put"
|
||||||
CMD_GET_QUERY = "get"
|
CMD_GET_QUERY = "get"
|
||||||
CMD_LS_QUERY = "ls"
|
CMD_LS_QUERY = "ls"
|
||||||
ALL_COMMANDS = {CMD_RUN, CMD_PUT_TX, CMD_GET_QUERY, CMD_LS_QUERY}
|
ALL_COMMANDS = {CMD_PUT_TX, CMD_GET_QUERY, CMD_LS_QUERY}
|
||||||
|
|
||||||
def verify_merkle_proof(result, proof, app_hash):
|
def verify_merkle_proof(result, proof, app_hash):
|
||||||
parts = proof.split(", ")
|
parts = proof.split(", ")
|
||||||
@ -44,13 +43,14 @@ def checked_abci_query(tmaddress, height, command, query, tentative_info):
|
|||||||
def print_response(attribute, value, always=False):
|
def print_response(attribute, value, always=False):
|
||||||
need_print = always or "v" in flags
|
need_print = always or "v" in flags
|
||||||
if need_print:
|
if need_print:
|
||||||
print attribute.upper() + ":", (8 - len(attribute)) * " ", value
|
print attribute + ":", (8 - len(attribute)) * " ", value
|
||||||
|
|
||||||
def print_checked_abci_query(tmaddress, height, command, query, tentative_info):
|
def print_checked_abci_query(tmaddress, height, command, query, tentative_info):
|
||||||
(height, result, proof, app_hash, success, message) = checked_abci_query(tmaddress, height, command, query, tentative_info)
|
(height, result, proof, app_hash, success, message) = checked_abci_query(tmaddress, height, command, query, tentative_info)
|
||||||
|
app_hash_to_show = "0x" + app_hash[0:6] if app_hash != "" else "--------"
|
||||||
print_response("height", height)
|
print_response("height", height)
|
||||||
print_response("app_hash", app_hash or "NOT_READY")
|
print_response("app_hash", app_hash_to_show or "NOT_READY")
|
||||||
print_response("proof", (proof or "NO_PROOF").upper())
|
# print_response("proof", (proof or "NO_PROOF").upper())
|
||||||
print result or "???"
|
print result or "???"
|
||||||
if not success:
|
if not success:
|
||||||
print_response("bad", message, True)
|
print_response("bad", message, True)
|
||||||
@ -76,13 +76,9 @@ tmaddress = sys.argv[1]
|
|||||||
command = sys.argv[2]
|
command = sys.argv[2]
|
||||||
flags = "".join(sys.argv[3:(num_args - 1)])
|
flags = "".join(sys.argv[3:(num_args - 1)])
|
||||||
arg = sys.argv[num_args - 1]
|
arg = sys.argv[num_args - 1]
|
||||||
if command in {CMD_PUT_TX, CMD_RUN}:
|
if command in {CMD_PUT_TX}:
|
||||||
if command == CMD_RUN:
|
tx = arg
|
||||||
query_key = "optarg"
|
query_key = tx.split("=")[0]
|
||||||
tx = query_key + "=" + arg
|
|
||||||
else:
|
|
||||||
tx = arg
|
|
||||||
query_key = tx.split("=")[0]
|
|
||||||
response = read_json(tmaddress + '/broadcast_tx_commit?tx="' + tx + '"')
|
response = read_json(tmaddress + '/broadcast_tx_commit?tx="' + tx + '"')
|
||||||
if "error" in response:
|
if "error" in response:
|
||||||
print_response("error", response["error"]["data"], True)
|
print_response("error", response["error"]["data"], True)
|
||||||
@ -93,12 +89,8 @@ if command in {CMD_PUT_TX, CMD_RUN}:
|
|||||||
print_response("bad", log or "NO_MESSAGE", True)
|
print_response("bad", log or "NO_MESSAGE", True)
|
||||||
else:
|
else:
|
||||||
info = response["result"].get("deliver_tx", {}).get("info")
|
info = response["result"].get("deliver_tx", {}).get("info")
|
||||||
if command in {CMD_RUN} and info is not None:
|
print_response("height", height)
|
||||||
wait_for_height(tmaddress, height + 1)
|
# print_response("info", info or "EMPTY") TODO: what is info?
|
||||||
print_checked_abci_query(tmaddress, height, "get", query_key, info)
|
|
||||||
else:
|
|
||||||
print_response("height", height)
|
|
||||||
print_response("info", info or "EMPTY")
|
|
||||||
elif command in {CMD_GET_QUERY, CMD_LS_QUERY}:
|
elif command in {CMD_GET_QUERY, CMD_LS_QUERY}:
|
||||||
height = latest_provable_height(tmaddress)
|
height = latest_provable_height(tmaddress)
|
||||||
print_checked_abci_query(tmaddress, height, command, arg, None)
|
print_checked_abci_query(tmaddress, height, command, arg, None)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 170 KiB |
Binary file not shown.
Before Width: | Height: | Size: 161 KiB |
Binary file not shown.
Before Width: | Height: | Size: 123 KiB |
@ -1,6 +1,5 @@
|
|||||||
kill $(ps aux | grep 'tendermint node' | awk '{print $2}')
|
CWD=`dirname $0`
|
||||||
kill $(ps aux | grep 'run 46.58' | awk '{print $2}')
|
$CWD/local-cluster-stop.sh
|
||||||
kill $(ps aux | grep 'judge' | awk '{print $2}')
|
|
||||||
|
|
||||||
rm -rf ~/.tendermint/cluster4/1
|
rm -rf ~/.tendermint/cluster4/1
|
||||||
rm -rf ~/.tendermint/cluster4/2
|
rm -rf ~/.tendermint/cluster4/2
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
source ./local-cluster-delete.sh
|
CWD=`dirname $0`
|
||||||
source ./local-cluster-init.sh
|
|
||||||
source ./local-cluster-start.sh
|
$CWD/local-cluster-delete.sh
|
||||||
|
$CWD/local-cluster-init.sh
|
||||||
|
$CWD/local-cluster-start.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user