demo: fix waitForBlocks

This commit is contained in:
Ethan Buchman 2017-02-16 15:36:46 -05:00
parent 35c221b496
commit 33cafd1b86
2 changed files with 7 additions and 5 deletions

View File

@ -85,9 +85,10 @@ func getHeaderAndCommit(c *cli.Context, height int) (*tmtypes.Header, *tmtypes.C
tmAddr := c.String("node")
clientURI := client.NewClientURI(tmAddr)
_, err := clientURI.Call("commit", map[string]interface{}{"height": height}, tmResult)
method := "commit"
_, err := clientURI.Call(method, map[string]interface{}{"height": height}, tmResult)
if err != nil {
return nil, nil, errors.New(cmn.Fmt("Error on broadcast tx: %v", err))
return nil, nil, errors.New(cmn.Fmt("Error on %s: %v", method, err))
}
resCommit := (*tmResult).(*ctypes.ResultCommit)
header := resCommit.Header

View File

@ -27,7 +27,7 @@ function waitForBlock() {
addr=$1
b1=`curl -s $addr/status | jq .result[1].latest_block_height`
b2=$b1
while [ "$b2" != "$b1" ]; do
while [ "$b2" == "$b1" ]; do
echo "Waiting for node $addr to commit a block ..."
sleep 1
b2=`curl -s $addr/status | jq .result[1].latest_block_height`
@ -94,10 +94,11 @@ echo "PACKET: $PACKET"
echo "PROOF: $PROOF"
# the query returns the height of the next block, which contains the app hash
# but which may not be committed yet, so we have to wait for it to query the commit
echo ""
echo "... waiting for some blocks to be mined"
echo "... waiting for a block to be committed"
echo ""
sleep 5
waitForBlock localhost:46657
waitForBlock localhost:36657