Skip to content

Commit

Permalink
squashme
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonNorthey92 committed Jun 5, 2024
1 parent 9e5af78 commit 89f4d4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion database/bfgd/scripts/0009.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ CREATE MATERIALIZED VIEW btc_blocks_can AS WITH RECURSIVE bb AS (
WHERE -- find the parent block via header -> parent hash
(
substr(bb.header, 5, 32) = btc_blocks.hash
AND bb.height > btc_blocks.height
)
),
__highest AS (
Expand Down
2 changes: 1 addition & 1 deletion e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ services:
BFG_POSTGRES_URI: "postgres://postgres@bfgd-postgres:5432/bfg?sslmode=disable"
BFG_BTC_START_HEIGHT: "1"
BFG_EXBTC_ADDRESS: "electrumx:50001"
BFG_LOG_LEVEL: "INFO"
BFG_LOG_LEVEL: "TRACE"
BFG_PUBLIC_ADDRESS: ":8383"
BFG_PRIVATE_ADDRESS: ":8080"

Expand Down
13 changes: 12 additions & 1 deletion service/bfg/bfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,24 @@ func (s *Server) invalidBlockChecker(ctx context.Context) {
}

log.Infof("received %d heights with no children, will re-check", len(heights))

// if all blocks have children, wait until next btc block to re-check
if len(heights) == 0 {
continue
}

// otherwise, reprocess blocks with missing children and re-check

for _, height := range heights {
log.Infof("reprocessing block at height %d", height)
if err := s.processBitcoinBlock(ctx, height); err != nil {
log.Errorf("error processing bitcoin block: %s", err)
}
}
s.queueCheckForInvalidBlocks()

go func() {
s.queueCheckForInvalidBlocks()
}()
}
}
}
Expand Down

0 comments on commit 89f4d4d

Please sign in to comment.