update submitblocks.sh, return an error if GetBlock height is too low, instead of crashing
This commit is contained in:
parent
39348100a9
commit
f8794dbe05
|
@ -143,7 +143,9 @@ func DarksideApplyStaged(height int) error {
|
|||
return errors.New("please call Reset first")
|
||||
}
|
||||
// Move the staged blocks into active list
|
||||
for _, blockBytes := range state.stagedBlocks {
|
||||
stagedBlocks := state.stagedBlocks
|
||||
state.stagedBlocks = nil
|
||||
for _, blockBytes := range stagedBlocks {
|
||||
if err := addBlockActive(blockBytes); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -329,6 +331,10 @@ func darksideRawRequest(method string, params []json.RawMessage) (json.RawMessag
|
|||
if height > state.latestHeight {
|
||||
return nil, errors.New(notFoundErr)
|
||||
}
|
||||
if height < state.startHeight {
|
||||
return nil, errors.New(fmt.Sprint("getblock: requesting height ", height,
|
||||
" is less than sapling activation height"))
|
||||
}
|
||||
index := height - state.startHeight
|
||||
return []byte("\"" + hex.EncodeToString(state.activeBlocks[index]) + "\""), nil
|
||||
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
set -e
|
||||
test $# -ne 2 && { echo usage: $0 sapling-height blocks-file;exit 1;}
|
||||
|
||||
JSON="{\"saplingActivation\": $1, \"branchID\": \"2bb40e60\", \"chainName\": \"main\"}"
|
||||
grpcurl -plaintext -d "$JSON" localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/SetMetaState
|
||||
# must do a Reset first
|
||||
grpcurl -plaintext -d '{"saplingActivation":'$1',"branchID":"2bb40e60","chainName":"main"}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/Reset
|
||||
|
||||
# send the blocks and make them active
|
||||
sed 's/^/{"block":"/;s/$/"}/' $2 |
|
||||
grpcurl -plaintext -d @ localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/SetBlocks
|
||||
grpcurl -plaintext -d @ localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/StageBlocksStream
|
||||
let latest=$1+$(cat $2|wc -l)-1
|
||||
grpcurl -plaintext -d '{"height":'$latest'}' localhost:9067 cash.z.wallet.sdk.rpc.DarksideStreamer/ApplyStaged
|
||||
|
|
Loading…
Reference in New Issue