Skip to content

Commit

Permalink
ci fix for missing blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 committed Oct 18, 2024
1 parent 62dabf5 commit 84e06dd
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,36 @@ jobs:
passphrase: ${{ secrets.SSH_PASSPHRASE }}
port: 22
script: |
# Ensure Rust installed via rustup is used
export PATH="$HOME/.cargo/bin:$PATH"
# Verify Cargo is available
cargo --version || { echo "Cargo not found"; exit 1; }
# Navigate to the project directory
cd fossil-headers-db
git fetch origin main
git reset --hard origin/main
# Build the project
cargo build --release
# Move the binary to the correct location
sudo mv target/release/fossil_headers_db /usr/local/bin/fossil_headers_db
# Restart the service
sudo systemctl daemon-reload
sudo systemctl restart fossil_headers_db
sudo systemctl status fossil_headers_db --no-pager
# Fetch the first missing block - 1 using PSQL
START_BLOCK=$(psql -U postgres -d fossil -t -c "
WITH block_range AS (
SELECT MIN(number) AS min_block, MAX(number) AS max_block
FROM public.blockheaders
), all_blocks AS (
SELECT n AS block_number
FROM generate_series(
(SELECT min_block FROM block_range),
(SELECT max_block FROM block_range)
) n
), missing_blocks AS (
SELECT all_blocks.block_number
FROM all_blocks
LEFT JOIN public.blockheaders bh ON all_blocks.block_number = bh.number
WHERE bh.number IS NULL
) SELECT MIN(block_number) - 1 FROM missing_blocks;")
# Run cargo with the calculated start block
nohup cargo run fix --start $START_BLOCK &

0 comments on commit 84e06dd

Please sign in to comment.