@@ -46,6 +46,7 @@ download_artifacts() {
46
46
local -r url=${1:? " No URL given to download_data function." } ;
47
47
local -r artifact=${2:? " No artifact type given to download_data function." } ;
48
48
local -r json_field=${3:? " No JSON field given to read from artifact list." } ;
49
+ local -r download_missing_certificate=${4:- false} ;
49
50
local -i nb=0
50
51
51
52
echo -n " Downloading ${artifact} data: "
@@ -55,12 +56,26 @@ download_artifacts() {
55
56
do
56
57
tput rc;
57
58
wget -O $DATA_DIR /${artifact} -${field} .json --quiet " ${url} /${field} "
59
+
60
+ if [ true = " $download_missing_certificate " ]; then
61
+ download_missing_certificate $( jq -r .certificate_hash $DATA_DIR /${artifact} -${field} .json) ;
62
+ fi
63
+
58
64
let " nb=nb+1"
59
65
echo -n " $nb "
60
66
done
61
67
echo " ✅" ;
62
68
}
63
69
70
+ # Download certificate if a file with the hash does not already exist
71
+ download_missing_certificate () {
72
+ local -r certificate_hash=${@:? " No certificate hashesgiven to download_missing_certificate function." } ;
73
+
74
+ if [ ! -e " $DATA_DIR /certificate-${certificate_hash} .json" ]; then
75
+ wget -O $DATA_DIR /certificate-${certificate_hash} .json --quiet " ${BASE_URL} /certificate/${certificate_hash} " ;
76
+ fi
77
+ }
78
+
64
79
download_certificate_chain () {
65
80
local parent_hash=$( jq -r .[0].hash $DATA_DIR /certificates.json) ;
66
81
local certificate_hash;
@@ -92,6 +107,8 @@ download_ctx_proof() {
92
107
do
93
108
tput rc;
94
109
wget -O $DATA_DIR /ctx-proof-${cardano_transaction_hash} .json --quiet " ${BASE_URL} /proof/cardano-transaction?transaction_hashes=${cardano_transaction_hash} " ;
110
+ download_missing_certificate $( jq -r .certificate_hash $DATA_DIR /ctx-proof-${cardano_transaction_hash} .json) ;
111
+
95
112
let " nb=nb+1"
96
113
echo -n " $nb "
97
114
done
@@ -102,7 +119,7 @@ write_ctx_proof_hashes_list() {
102
119
local -r ctx_hashes=${@:? " No cardano transaction hashes given to write_ctx_proof_hashes_list function." } ;
103
120
local -i nb=0
104
121
105
- echo -n " Downloading cardano transaction proof: "
122
+ echo -n " Writting cardano transaction proof ids to a file : "
106
123
tput sc;
107
124
108
125
echo " [" > $DATA_DIR /ctx-proofs.json
@@ -158,10 +175,10 @@ download_artifacts "$BASE_URL/certificate" "certificate" "hash"
158
175
download_certificate_chain
159
176
160
177
download_data " $BASE_URL /artifact/snapshots" " snapshots"
161
- download_artifacts " $BASE_URL /artifact/snapshot" " snapshot" " digest"
178
+ download_artifacts " $BASE_URL /artifact/snapshot" " snapshot" " digest" true
162
179
163
180
download_data " $BASE_URL /artifact/mithril-stake-distributions" " mithril-stake-distributions"
164
- download_artifacts " $BASE_URL /artifact/mithril-stake-distribution" " mithril-stake-distribution" " hash"
181
+ download_artifacts " $BASE_URL /artifact/mithril-stake-distribution" " mithril-stake-distribution" " hash" true
165
182
166
183
download_data " $BASE_URL /artifact/cardano-transactions" " ctx-commitments"
167
184
download_artifacts " $BASE_URL /artifact/cardano-transaction" " ctx-commitment" " hash"
0 commit comments