Repository navigation
fix: route the block-height and block-hash HTTP endpoints - #59
Closed
setavenger wants to merge 1 commit into
Closed
setavenger wants to merge 1 commit into
setavenger wants to merge 1 commit into
Conversation
GetBestBlockHeight and GetBlockHashByHeight have existed on the HTTP handler since the v2 refactor but were never registered in RunServer, so both returned 404. The same two calls are exposed over gRPC, so only HTTP-only clients were affected. The routes are documented in the README that #30 merged (GET /block-height, GET /block-hash/:blockheight); the registrations were lost when the server moved to internal/. This restores them at those paths and re-adds them to the endpoint list in the current README. /block-hash/:blockheight is what a client needs to detect a reorg without holding the chain: store the hash of the last n scanned blocks and walk back while the server disagrees. That is the request in #29. No handler code changes. Both handlers read data the already-routed endpoints depend on (GetBlockHashByHeight backs /utxos, /tweaks, /spent-outputs, /compute-index and /full-block; GetChainTip backs /info), so no new data dependency is introduced, and the hash byte order matches the gRPC implementation. Refs #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetBestBlockHeightandGetBlockHashByHeighthave existed on the HTTP handler (internal/server/handler.go:45,:59) since the v2 refactor, butRunServernever registered them, so both returned 404 over HTTP. The same two calls are reachable over gRPC (internal/server/v2/service.go:59,:75), so only HTTP-only clients were affected.Both routes are documented in the README that #30 merged —
GET /block-heightandGET /block-hash/:blockheight. The registrations were lost when the server moved intointernal/. This restores them at those paths, so clients written against the documented API work again, and re-adds them to the endpoint list in the current README, which had dropped them too./block-hash/:blockheightis the piece a light client needs to handle a reorg without holding the chain: remember the hash of the last n scanned blocks, and before scanning walk backwards while the server disagrees, rolling back each block. That is the request in #29.Scope
No handler code changed — this is two
router.GETlines and two README bullets. In particular I did not reclassify the endpoints: I listed both under the existing Deprecated (JSON convenience) heading, since each mirrors a gRPC call. If you would rather/block-heightsit next to/infoas supported discovery, say so and I will move it.Verification
go build ./...— clean.go vet ./internal/server/...— clean.go test ./...—internal/indexerok,internal/typesok; every other package reports no test files.internal/serverhas no test suite, so nothing in the repo covers routing.go.mod) and exercised it withhttptest: registration does not panic,GET /block-height→ 200,GET /block-hash/840000→ 200 withblockheightbound to840000, existing routes unaffected, unknown paths still 404. That verifies the path patterns coexist without wildcard conflict; it does not exercise the real handlers.GetBlockHashByHeightbacks/utxos,/tweaks,/spent-outputs,/compute-indexand/full-block;GetChainTipbacks/info— so no new data dependency is introduced. Hash byte order (ReverseBytesCopy) matches the gRPC implementation.Refs #29
Note
Low Risk
Routing and documentation only; handler logic is unchanged and mirrors existing gRPC behavior.
Overview
Restores two documented HTTP routes that were implemented on the handler but never registered in
RunServer, soGET /block-heightandGET /block-hash/:blockheighthad been returning 404 for HTTP-only clients while the same data remained available over gRPC.internal/server/run.gonow wiresGetBestBlockHeightandGetBlockHashByHeightat those paths. The root README endpoint list again includes both under the existing Deprecated JSON convenience section, including the reorg-detection use case for block hash by height.Reviewed by Cursor Bugbot for commit 620fcd8. Configure here.