Test with attestation cache
This commit is contained in:
parent
3b54e0cb8c
commit
ed2cd259e9
6 changed files with 59 additions and 5 deletions
BIN
.ots/810d26b7af9c5d306e77fec290d360c7ac876b2e.ots
Normal file
BIN
.ots/810d26b7af9c5d306e77fec290d360c7ac876b2e.ots
Normal file
Binary file not shown.
|
|
@ -7,3 +7,9 @@ c0685dabfb48360a3abc103b75357f94e9f054b2:46aded7b9582bbed673843e2cf8a3f8fa742ad9
|
||||||
4a6f5ed0c12315b0bc8a0fa5815ada1bd20e5963:db6f29e01a33d8ed8f127ff169d9f91d55e8a229
|
4a6f5ed0c12315b0bc8a0fa5815ada1bd20e5963:db6f29e01a33d8ed8f127ff169d9f91d55e8a229
|
||||||
db6f29e01a33d8ed8f127ff169d9f91d55e8a229:392ee723c3cf626d0e5281aa94771d7133bb345e
|
db6f29e01a33d8ed8f127ff169d9f91d55e8a229:392ee723c3cf626d0e5281aa94771d7133bb345e
|
||||||
392ee723c3cf626d0e5281aa94771d7133bb345e:392ee723c3cf626d0e5281aa94771d7133bb345e^1
|
392ee723c3cf626d0e5281aa94771d7133bb345e:392ee723c3cf626d0e5281aa94771d7133bb345e^1
|
||||||
|
810d26b7af9c5d306e77fec290d360c7ac876b2e:c0685dabfb48360a3abc103b75357f94e9f054b2
|
||||||
|
c0685dabfb48360a3abc103b75357f94e9f054b2:46aded7b9582bbed673843e2cf8a3f8fa742ad91
|
||||||
|
46aded7b9582bbed673843e2cf8a3f8fa742ad91:4a6f5ed0c12315b0bc8a0fa5815ada1bd20e5963
|
||||||
|
4a6f5ed0c12315b0bc8a0fa5815ada1bd20e5963:db6f29e01a33d8ed8f127ff169d9f91d55e8a229
|
||||||
|
db6f29e01a33d8ed8f127ff169d9f91d55e8a229:392ee723c3cf626d0e5281aa94771d7133bb345e
|
||||||
|
392ee723c3cf626d0e5281aa94771d7133bb345e:392ee723c3cf626d0e5281aa94771d7133bb345e^1
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
c0685dabfb48360a3abc103b75357f94e9f054b2
|
810d26b7af9c5d306e77fec290d360c7ac876b2e
|
||||||
|
|
|
||||||
BIN
.ots/proof.ots
BIN
.ots/proof.ots
Binary file not shown.
|
|
@ -37,6 +37,39 @@ chmod +x "$GENERATE_SCRIPT"
|
||||||
# Ensure .ots directory exists
|
# Ensure .ots directory exists
|
||||||
mkdir -p .ots
|
mkdir -p .ots
|
||||||
|
|
||||||
|
# Cache file for attestation status (avoids repeated ots info calls)
|
||||||
|
STATUS_CACHE=".ots/.attestation-cache"
|
||||||
|
if [ ! -f "$STATUS_CACHE" ]; then
|
||||||
|
echo "# Attestation status cache" > "$STATUS_CACHE"
|
||||||
|
echo "# Format: commit-hash:status:timestamp" >> "$STATUS_CACHE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to check cached status
|
||||||
|
get_cached_status() {
|
||||||
|
local commit="$1"
|
||||||
|
local cache_line=$(grep "^$commit:" "$STATUS_CACHE" 2>/dev/null | tail -1)
|
||||||
|
if [ -n "$cache_line" ]; then
|
||||||
|
local status=$(echo "$cache_line" | cut -d: -f2)
|
||||||
|
local timestamp=$(echo "$cache_line" | cut -d: -f3)
|
||||||
|
local now=$(date +%s)
|
||||||
|
local age=$((now - timestamp))
|
||||||
|
# Cache valid for 1 hour (3600 seconds)
|
||||||
|
if [ "$age" -lt 3600 ]; then
|
||||||
|
echo "$status"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to cache status
|
||||||
|
cache_status() {
|
||||||
|
local commit="$1"
|
||||||
|
local status="$2"
|
||||||
|
local now=$(date +%s)
|
||||||
|
echo "$commit:$status:$now" >> "$STATUS_CACHE"
|
||||||
|
}
|
||||||
|
|
||||||
echo "[ots-backfill] Scanning commit history..."
|
echo "[ots-backfill] Scanning commit history..."
|
||||||
|
|
||||||
# Get all commit hashes (oldest to newest)
|
# Get all commit hashes (oldest to newest)
|
||||||
|
|
@ -55,18 +88,31 @@ for COMMIT in $COMMITS; do
|
||||||
PROOF_FILE=".ots/${COMMIT}.ots"
|
PROOF_FILE=".ots/${COMMIT}.ots"
|
||||||
|
|
||||||
if [ -f "$PROOF_FILE" ]; then
|
if [ -f "$PROOF_FILE" ]; then
|
||||||
# Check if already fully attested
|
# Check cached status first
|
||||||
STATUS=$(ots info "$PROOF_FILE" 2>&1 | grep -c "PendingAttestation" || echo "0")
|
CACHED_STATUS=$(get_cached_status "$COMMIT" || echo "")
|
||||||
|
|
||||||
if [ "$STATUS" -eq 0 ]; then
|
if [ "$CACHED_STATUS" = "attested" ]; then
|
||||||
echo " ✓ Already attested (skipping)"
|
echo " ✓ Already attested (cached, skipping)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if already fully attested (only if not cached or cache expired)
|
||||||
|
PENDING_COUNT=$(ots info "$PROOF_FILE" 2>&1 | grep -c "PendingAttestation" || echo "0")
|
||||||
|
|
||||||
|
if [ "$PENDING_COUNT" -eq 0 ]; then
|
||||||
|
echo " ✓ Already attested"
|
||||||
|
cache_status "$COMMIT" "attested"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cache as pending
|
||||||
|
cache_status "$COMMIT" "pending"
|
||||||
|
|
||||||
# Try to upgrade existing proof (only contacts calendars if pending)
|
# Try to upgrade existing proof (only contacts calendars if pending)
|
||||||
echo " Upgrading pending proof..."
|
echo " Upgrading pending proof..."
|
||||||
if ots upgrade "$PROOF_FILE" 2>/dev/null; then
|
if ots upgrade "$PROOF_FILE" 2>/dev/null; then
|
||||||
echo " ✓ Upgraded to attested"
|
echo " ✓ Upgraded to attested"
|
||||||
|
cache_status "$COMMIT" "attested"
|
||||||
UPDATED=$((UPDATED + 1))
|
UPDATED=$((UPDATED + 1))
|
||||||
else
|
else
|
||||||
echo " - Still pending (no upgrade available yet)"
|
echo " - Still pending (no upgrade available yet)"
|
||||||
|
|
@ -76,6 +122,7 @@ for COMMIT in $COMMITS; do
|
||||||
echo " Generating new proof..."
|
echo " Generating new proof..."
|
||||||
"$GENERATE_SCRIPT" "$COMMIT" "$PROOF_FILE" >/dev/null 2>&1
|
"$GENERATE_SCRIPT" "$COMMIT" "$PROOF_FILE" >/dev/null 2>&1
|
||||||
echo " ✓ Generated proof"
|
echo " ✓ Generated proof"
|
||||||
|
cache_status "$COMMIT" "pending"
|
||||||
UPDATED=$((UPDATED + 1))
|
UPDATED=$((UPDATED + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
1
test6.txt
Normal file
1
test6.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
# Second test with cache
|
||||||
Loading…
Add table
Add a link
Reference in a new issue