-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_block_data.sh
More file actions
51 lines (44 loc) · 1.11 KB
/
fetch_block_data.sh
File metadata and controls
51 lines (44 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# This script is for fetch specific block in fabric-cli container.
#
# You can use $ ./fetch_block_data.sh {block_num}
# {block_num} options: number, newest, oldest
function getEnv() {
PEER=$1
if [[ "$PEER" == "peer1" ]]; then
export MSPID=""
export MSPPATH=""
export PEER_ADDRESS=""
elif [[ "$PEER" == "peer2" ]]; then
export MSPID=""
export MSPPATH=""
export PEER_ADDRESS=""
else
echo "Wrong arg"
fi
}
function fetchBlock() {
ORDERER_URL=""
CHANNEL_NAME=""
# Peer1
getEnv "peer1"
peer channel fetch "$BLOCK_NUM" \
-o "$ORDERER_URL" \
-c "$CHANNEL_NAME" \
./peer1_block.block
# Peer2
getEnv "peer2"
peer channel fetch "$BLOCK_NUM" \
-o "$ORDERER_URL" \
-c "$CHANNEL_NAME" \
./peer2_block.block
}
function decodeBlock() {
# Decoding to readable file
~/utils/bin/configtxlator proto_decode --input ./peer1_block.block --type common.Block > ./peer1_block.json
~/utils/bin/configtxlator proto_decode --input ./peer2_block.block --type common.Block > ./peer2_block.json
}
BLOCK_NUM=$1
fetchBlock
decodeBlock