Skip to content

Commit 19f68ea

Browse files
authored
Merge pull request #53 from spacesprotocol/addr
Use GET for resolve
2 parents edbe7b8 + 017b37d commit 19f68ea

17 files changed

Lines changed: 309 additions & 138 deletions

File tree

Cargo.lock

Lines changed: 49 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fabric/go/fabric.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -760,27 +760,44 @@ func (f *Fabric) query(request QueryRequest) (*libveritas.VerifiedMessage, error
760760
}
761761

762762
func (f *Fabric) sendQuery(ctx *libveritas.QueryContext, request QueryRequest, relays []string) (*libveritas.VerifiedMessage, error) {
763+
var qParts []string
764+
var hintParts []string
763765
for _, q := range request.Queries {
764766
ctx.AddRequest(q.Space)
767+
qParts = append(qParts, q.Space)
765768
for _, h := range q.Handles {
766769
if h != "" {
767770
ctx.AddRequest(h + q.Space)
771+
qParts = append(qParts, h+q.Space)
768772
}
769773
}
770-
}
771-
772-
body, err := json.Marshal(request)
773-
if err != nil {
774-
return nil, fmt.Errorf("encoding query: %w", err)
774+
if q.EpochHint != nil {
775+
hintParts = append(hintParts, fmt.Sprintf("%s:%s:%d", q.Space, q.EpochHint.Root, q.EpochHint.Height))
776+
}
775777
}
776778

777779
var lastErr error = &FabricError{Code: "no_peers", Message: "no peers available"}
778780

779781
for _, u := range relays {
780-
respBytes, err := postBinary(f.client, u+"/query", body)
782+
queryURL, _ := url.Parse(u + "/query")
783+
params := url.Values{}
784+
params.Set("q", strings.Join(qParts, ","))
785+
if len(hintParts) > 0 {
786+
params.Set("hints", strings.Join(hintParts, ","))
787+
}
788+
queryURL.RawQuery = params.Encode()
789+
790+
resp, err := f.client.Get(queryURL.String())
781791
if err != nil {
782792
f.pool.MarkFailed(u)
783-
lastErr = err
793+
lastErr = &FabricError{Code: "http", Message: err.Error()}
794+
continue
795+
}
796+
respBytes, _ := io.ReadAll(resp.Body)
797+
resp.Body.Close()
798+
if resp.StatusCode >= 300 {
799+
f.pool.MarkFailed(u)
800+
lastErr = &FabricError{Code: "relay", Status: resp.StatusCode, Message: string(respBytes)}
784801
continue
785802
}
786803

fabric/go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22
44

55
require (
66
github.com/btcsuite/btcd/btcec/v2 v2.3.6
7-
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401060756
7+
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401232107
88
)
99

1010
require (

fabric/go/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK
88
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
99
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
1010
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
11-
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401060756 h1:OBef908r/1+Tw+P6maj2gsv+RToyiH1uSgbPiS9CDxw=
12-
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401060756/go.mod h1:HXnX2FNL43ueJuedsQwX9GF5jRHYZLqXYfFLWz900H8=
11+
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401232107 h1:G6iAm4v0s08uKtVys3h8oDeJ2gMTwjpXcODHq1Mazis=
12+
github.com/spacesprotocol/libveritas-go v0.0.0-dev.20260401232107/go.mod h1:HXnX2FNL43ueJuedsQwX9GF5jRHYZLqXYfFLWz900H8=

0 commit comments

Comments
 (0)