Skip to content

Commit

Permalink
use fork
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe committed Jun 8, 2024
1 parent eace066 commit e5dafb3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 203 deletions.
2 changes: 2 additions & 0 deletions impl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/anacrolix/dht/v2 => github.com/TBD54566975/dht/v2 v2.0.0-20240608032934-ba76f42385e2
4 changes: 2 additions & 2 deletions impl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrX
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/TBD54566975/dht/v2 v2.0.0-20240608032934-ba76f42385e2 h1:0GTtlMBSXdqzLVFLAIVCOI2M4E7uO16Z6QFbpwRdKLg=
github.com/TBD54566975/dht/v2 v2.0.0-20240608032934-ba76f42385e2/go.mod h1:SDGC+sEs1pnO2sJGYuhvIis7T8749dDHNfcjtdH4e3g=
github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20240410030603-dcd73d6ce8b3 h1:JgCGL4PSKuSHVRQL9onEf+e3Ti1DpCnLWTIP2tg9iDg=
github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20240410030603-dcd73d6ce8b3/go.mod h1:nyTjplXnrari2nQg63ztI4C0rgMb7Jjn3gfn0OM656g=
github.com/alecthomas/assert/v2 v2.0.0-alpha3 h1:pcHeMvQ3OMstAWgaeaXIAL8uzB9xMm2zlxt+/4ml8lk=
Expand All @@ -30,8 +32,6 @@ github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3b
github.com/allegro/bigcache/v3 v3.1.0/go.mod h1:aPyh7jEvrog9zAwx5N7+JUQX5dZTSGpxF1LAR4dr35I=
github.com/anacrolix/chansync v0.3.0 h1:lRu9tbeuw3wl+PhMu/r+JJCRu5ArFXIluOgdF0ao6/U=
github.com/anacrolix/chansync v0.3.0/go.mod h1:DZsatdsdXxD0WiwcGl0nJVwyjCKMDv+knl1q2iBjA2k=
github.com/anacrolix/dht/v2 v2.21.1 h1:s1rKkfLLcmBHKv4v/mtMkIeHIEptzEFiB6xVu54+5/o=
github.com/anacrolix/dht/v2 v2.21.1/go.mod h1:SDGC+sEs1pnO2sJGYuhvIis7T8749dDHNfcjtdH4e3g=
github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
github.com/anacrolix/envpprof v1.0.0/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
github.com/anacrolix/envpprof v1.1.0/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4=
Expand Down
194 changes: 0 additions & 194 deletions impl/internal/dht/getput.go

This file was deleted.

8 changes: 4 additions & 4 deletions impl/pkg/dht/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
errutil "github.com/TBD54566975/ssi-sdk/util"
"github.com/anacrolix/dht/v2"
"github.com/anacrolix/dht/v2/bep44"
"github.com/anacrolix/dht/v2/exts/getput"
"github.com/anacrolix/log"
"github.com/anacrolix/torrent/types/infohash"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"golang.org/x/time/rate"

dhtint "github.com/TBD54566975/did-dht/internal/dht"
"github.com/TBD54566975/did-dht/internal/util"
"github.com/TBD54566975/did-dht/pkg/telemetry"
)
Expand Down Expand Up @@ -92,7 +92,7 @@ func (d *DHT) Put(ctx context.Context, request bep44.Put) (string, error) {
}

key := util.Z32Encode(request.K[:])
t, err := dhtint.Put(ctx, request.Target(), d.Server, nil, func(int64) bep44.Put {
t, err := getput.Put(ctx, request.Target(), d.Server, nil, func(int64) bep44.Put {
return request
})
if err != nil {
Expand All @@ -109,15 +109,15 @@ func (d *DHT) Put(ctx context.Context, request bep44.Put) (string, error) {
// GetFull returns the full BEP-44 result for the given key from the DHT, using our modified
// implementation of getput.Get. It should ONLY be used when it's needed to get the signature
// data for a record.
func (d *DHT) GetFull(ctx context.Context, key string) (*dhtint.FullGetResult, error) {
func (d *DHT) GetFull(ctx context.Context, key string) (*getput.GetResult, error) {
ctx, span := telemetry.GetTracer().Start(ctx, "DHT.GetFull")
defer span.End()

z32Decoded, err := util.Z32Decode(key)
if err != nil {
return nil, errors.Wrapf(err, "failed to decode key [%s]", key)
}
res, t, err := dhtint.Get(ctx, infohash.HashBytes(z32Decoded), d.Server, nil, nil)
res, t, err := getput.Get(ctx, infohash.HashBytes(z32Decoded), d.Server, nil, nil)
if err != nil {
return nil, fmt.Errorf("failed to get key[%s] from dht; tried %d nodes, got %d responses", key, t.NumAddrsTried, t.NumResponses)
}
Expand Down
5 changes: 2 additions & 3 deletions impl/pkg/dht/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import (

"github.com/TBD54566975/ssi-sdk/util"
"github.com/anacrolix/dht/v2/bep44"
"github.com/anacrolix/dht/v2/exts/getput"
"github.com/anacrolix/torrent/bencode"
"github.com/miekg/dns"

"github.com/TBD54566975/did-dht/internal/dht"
)

// CreateDNSPublishRequest creates a put request for the given records. Requires a public/private keypair and
Expand Down Expand Up @@ -51,7 +50,7 @@ func CreateDNSPublishRequest(privateKey ed25519.PrivateKey, msg dns.Msg) (*bep44

// ParseDNSGetResponse parses the response from a get request.
// The response is expected to be a slice of DNS resource records.
func ParseDNSGetResponse(response dht.FullGetResult) (*dns.Msg, error) {
func ParseDNSGetResponse(response getput.GetResult) (*dns.Msg, error) {
var payload string
if err := bencode.Unmarshal(response.V, &payload); err != nil {
return nil, util.LoggingErrorMsg(err, "failed to unmarshal payload value")
Expand Down

0 comments on commit e5dafb3

Please sign in to comment.