This repository has been archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Format out explorer * Upgrade base image to Ubuntu LTS Co-authored-by: Stefan Bussemaker <[email protected]>
- Loading branch information
1 parent
343e6f0
commit 611f3f5
Showing
6 changed files
with
117 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,29 @@ | ||
#!/bin/bash | ||
|
||
init_chain() { | ||
echo "Init a chain: $CHAINNAME." | ||
|
||
multichain-util create $CHAINNAME \ | ||
-datadir=/data | ||
|
||
# Set some required parameters in the params.dat | ||
sed -i "s/^default-network-port.*/default-network-port = $NETWORK_PORT/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^default-rpc-port.*/default-rpc-port = $RPC_PORT/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^chain-name.*/chain-name = $CHAINNAME/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^chain-description.*/chain-description = MultiChain $CHAINNAME/" /data/$CHAINNAME/params.dat | ||
|
||
# Loop over all variables that start with PARAM_: e.g. PARAM_BLOCKTIME='target-block-time|40'; | ||
( set -o posix ; set ) | sed -n '/^PARAM_/p' | while read PARAM; do | ||
IFS='=' read -ra KV <<< "$PARAM" | ||
IFS='|' read -ra KV <<< "${!KV[0]}" | ||
sed -i "s/^${KV[0]}.*/${KV[0]} = ${KV[1]}/" /data/$CHAINNAME/params.dat | ||
done | ||
} | ||
set -m | ||
|
||
wait() { | ||
echo "Waiting for $1 seconds" | ||
sleep $1 | ||
} | ||
|
||
start_main_node () { | ||
echo "Start main node with chain: $CHAINNAME." | ||
|
||
if [ ! -d /data/$CHAINNAME ]; then | ||
init_chain | ||
start () { | ||
if [[ $DELAY_INIT == 1 ]]; then | ||
wait 10 | ||
fi | ||
|
||
cat /data/$CHAINNAME/params.dat | ||
|
||
cat << EOF > /data/$CHAINNAME/multichain.conf | ||
rpcuser=$RPC_USER | ||
rpcpassword=$RPC_PASSWORD | ||
rpcallowip=$RPC_ALLOW_IP | ||
rpcport=$RPC_PORT | ||
EOF | ||
cp /data/$CHAINNAME/multichain.conf /data/multichain.conf | ||
if [ -z "$MAIN_NODE_HOST" ]; then | ||
./multichain.sh & | ||
./streams.sh | ||
|
||
multichaind $CHAINNAME \ | ||
-daemon \ | ||
-txindex \ | ||
-shrinkdebugfilesize \ | ||
-datadir=/data \ | ||
-initprivkey=$PRIVATE_KEY | ||
|
||
wait 10 | ||
|
||
for stream in 'legalentity' 'sensordevice' 'observationgoal' ; | ||
do | ||
echo "Creating stream: $stream" | ||
multichain-cli $CHAINNAME -datadir=/data create stream $stream true | ||
done | ||
} | ||
|
||
start_node () { | ||
if [[ $MAIN_NODE_HOST =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
IP=$MAIN_NODE_HOST | ||
fg %1 | ||
else | ||
IP=$(dig +short $MAIN_NODE_HOST) | ||
./multichain.sh | ||
fi | ||
|
||
echo "Start node with existing chain: $CHAINNAME from $IP:$NETWORK_PORT" | ||
|
||
multichaind $CHAINNAME@$IP:$NETWORK_PORT \ | ||
-daemon \ | ||
-txindex \ | ||
-shrinkdebugfilesize \ | ||
-rpcuser=$RPC_USER \ | ||
-rpcpassword=$RPC_PASSWORD \ | ||
-rpcallowip=$RPC_ALLOW_IP \ | ||
-rpcport=$RPC_PORT \ | ||
-datadir=/data \ | ||
-initprivkey=$PRIVATE_KEY | ||
|
||
wait 10 | ||
} | ||
|
||
start_explorer() { | ||
echo "Run the explorer" | ||
|
||
cat << EOF > /data/$CHAINNAME/multichain.conf | ||
rpcuser=$RPC_USER | ||
rpcpassword=$RPC_PASSWORD | ||
rpcallowip=$RPC_ALLOW_IP | ||
rpcport=$RPC_PORT | ||
EOF | ||
|
||
cat << EOF > /root/explorer.conf | ||
port 2750 | ||
host 0.0.0.0 | ||
datadir += [{ | ||
"dirname": "/data/$CHAINNAME", | ||
"loader": "default", | ||
"chain": "MultiChain $CHAINNAME", | ||
"policy": "MultiChain" | ||
}] | ||
dbtype = sqlite3 | ||
connect-args = dockerchain.explorer.sqlite | ||
EOF | ||
|
||
python -m Mce.abe --config /root/explorer.conf --commit-bytes 100000 --no-serve | ||
wait 5 | ||
python -m Mce.abe --config /root/explorer.conf | ||
} | ||
|
||
|
||
if [[ $DELAY_INIT == 1 ]]; then | ||
wait 10 | ||
fi | ||
|
||
if [ -z "$MAIN_NODE_HOST" ]; then | ||
start_main_node | ||
if [ "$1" = "start" ]; then | ||
start | ||
else | ||
start_node | ||
exec "$@" | ||
fi | ||
|
||
start_explorer |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
|
||
set -m | ||
|
||
init_chain() { | ||
echo "Init a chain: $CHAINNAME." | ||
|
||
multichain-util create $CHAINNAME \ | ||
-datadir=/data | ||
|
||
# Set some required parameters in the params.dat | ||
sed -i "s/^default-network-port.*/default-network-port = $NETWORK_PORT/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^default-rpc-port.*/default-rpc-port = $RPC_PORT/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^chain-name.*/chain-name = $CHAINNAME/" /data/$CHAINNAME/params.dat | ||
sed -i "s/^chain-description.*/chain-description = MultiChain $CHAINNAME/" /data/$CHAINNAME/params.dat | ||
|
||
# Loop over all variables that start with PARAM_: e.g. PARAM_BLOCKTIME='target-block-time|40'; | ||
( set -o posix ; set ) | sed -n '/^PARAM_/p' | while read PARAM; do | ||
IFS='=' read -ra KV <<< "$PARAM" | ||
IFS='|' read -ra KV <<< "${!KV[0]}" | ||
sed -i "s/^${KV[0]}.*/${KV[0]} = ${KV[1]}/" /data/$CHAINNAME/params.dat | ||
done | ||
} | ||
|
||
start_main_node () { | ||
echo "Start main node with chain: $CHAINNAME." | ||
|
||
if [ ! -d /data/$CHAINNAME ]; then | ||
init_chain | ||
fi | ||
|
||
cat /data/$CHAINNAME/params.dat | ||
|
||
cat << EOF > /data/$CHAINNAME/multichain.conf | ||
rpcuser=$RPC_USER | ||
rpcpassword=$RPC_PASSWORD | ||
rpcallowip=$RPC_ALLOW_IP | ||
rpcport=$RPC_PORT | ||
EOF | ||
cp /data/$CHAINNAME/multichain.conf /data/multichain.conf | ||
|
||
exec multichaind $CHAINNAME \ | ||
-txindex \ | ||
-shrinkdebugfilesize \ | ||
-datadir=/data \ | ||
-initprivkey=$PRIVATE_KEY | ||
} | ||
|
||
start_node () { | ||
if [[ $MAIN_NODE_HOST =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
IP=$MAIN_NODE_HOST | ||
else | ||
IP=$(dig +short $MAIN_NODE_HOST) | ||
fi | ||
|
||
echo "Start node with existing chain: $CHAINNAME from $IP:$NETWORK_PORT" | ||
|
||
exec multichaind $CHAINNAME@$IP:$NETWORK_PORT \ | ||
-txindex \ | ||
-shrinkdebugfilesize \ | ||
-rpcuser=$RPC_USER \ | ||
-rpcpassword=$RPC_PASSWORD \ | ||
-rpcallowip=$RPC_ALLOW_IP \ | ||
-rpcport=$RPC_PORT \ | ||
-datadir=/data \ | ||
-initprivkey=$PRIVATE_KEY | ||
} | ||
|
||
if [ -z "$MAIN_NODE_HOST" ]; then | ||
start_main_node | ||
else | ||
start_node | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -m | ||
|
||
wait() { | ||
echo "Waiting for $1 seconds" | ||
sleep $1 | ||
} | ||
|
||
create_streams () { | ||
for stream in 'legalentity' 'sensordevice' 'observationgoal' ; | ||
do | ||
echo "Creating stream: $stream" | ||
multichain-cli $CHAINNAME -datadir=/data create stream $stream true | ||
done | ||
} | ||
|
||
# Wait a bit as the Multichain daemon is started in background. This prevents | ||
# racing conditions where multichain-cli tries to create streams while the chain | ||
# isn't created yet | ||
wait 10 | ||
|
||
create_streams |