-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbtc-bench.bash
More file actions
82 lines (68 loc) · 1.94 KB
/
btc-bench.bash
File metadata and controls
82 lines (68 loc) · 1.94 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
startTime=$(date +%Y-%d-%mT%T%z)
startTimeSeconds=$(date +%s)
logFile="bitcoin_bench_""$startTimeSeconds"".log"
#######################################
# $nSeconds sets an rpc call #
# every 2 seconds; increase #
# for slower systems. #
#######################################
# 6 GB default dbcache size; #
# descrease for older systems #
# with less memory #
#######################################
nSeconds=2
dbCacheMbytes=6000
currentBlockHeight=394395
bitcoindCmd="./bitcoind --dbcache=$dbCacheMbytes &"
e='echo -e'
$e
$e
$e "$(uname -a)" >> $logFile
$e "Writing to file: ./$logfile"
$e
$e
a=$startTime
b=$startTimeSeconds
c=$logFile
d=$nSeconds
e=$currentBlockHeight
f=$dbCacheMbytes
g=$bitcoindCmd
$e >> $logfile
$e "Time:\t\t$a" >> $logfile
$e "Unix Start Time:\t\t$b" >> $logfile
$e "Log File Name:\t\t$c" >> $logfile
$e "Recording:\t\t$g" >> $logfile
$e "timeout:\t\t$d" >> $logfile
$e "CurrentBlockheight\t\t$e" >> $logfile
$e "dbcahce:\t\t$f MB" >> $logFile
$e >> $logfile
#######################################
# warns users not to proceed #
# with their wallets in the #
# data directory #
#######################################
if [[ -a "$HOME/.bitcoin" ]]; then
$e
$e "\n\n################"
$e "\tERROR:\t$HOME/.bitcoin exists."
$e "This directory may store your"
$e "wallet data. Please make a "
$e "backup of wallet.dat, remove "
$e "$HOME/.bitcoin, and try again."
$e "\n\tAborting now."
$e "################"
$e
exit 1;
fi
$e "START TIME:\t$startTime" >> "$logFile"
message="Executing\t$bitcoindCmd\tevery $nSeconds seconds"
$e $message >> $logFile;
$e $message
./bitcoind -dbcache=$dbCacheMbytes &
while :
do
$e "blockcount: $(./bitcoin-cli getblockcount)\tTime: $(date +%Y-%m-%dT%T)\tTime Elapsed (sec): $(($(date +%s)-b))\tUnixTime (sec): $(date +%s)" >> "$logFile"
sleep "$nSeconds"
done