Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Relay API in the spec itself #198

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions impl/pkg/service/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,11 @@ func (s *DHTService) republishBatch(ctx context.Context, wg *sync.WaitGroup, rec
putCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()

_, putErr := s.dht.Put(putCtx, record.Put())
if putErr != nil {
if _, putErr := s.dht.Put(putCtx, record.Put()); putErr != nil {
if errors.Is(putErr, context.DeadlineExceeded) {
logrus.WithContext(putCtx).WithField("record_id", id).Info("republish timeout exceeded")
logrus.WithContext(putCtx).WithField("record_id", id).Debug("republish timeout exceeded")
} else {
logrus.WithContext(putCtx).WithField("record_id", id).WithError(putErr).Info("failed to republish record")
logrus.WithContext(putCtx).WithField("record_id", id).WithError(putErr).Debug("failed to republish record")
}
failedRecordsChan <- failedRecord{
record: record,
Expand Down Expand Up @@ -368,7 +367,8 @@ func (s *DHTService) handleFailedRecords(ctx context.Context, failedRecords []fa
logrus.WithContext(ctx).WithError(err).Error("failed to get failed record count")
return
}
logrus.WithContext(ctx).WithField("failed_record_count", failedRecordCnt).Warn("total failed records")

logrus.WithContext(ctx).WithField("failed_record_count", failedRecordCnt).Warn("total count of record that failed to republish")
}

// Close closes the Mainline service gracefully
Expand Down
20 changes: 10 additions & 10 deletions spec/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ paths:
/{id}:
get:
tags:
- Pkarr Relay
summary: Get Pkarr records from the DHT
description: Get a Pkarr record set from the DHT
- DHT
summary: Get DNS-encoded BEP44 records from the DHT
description: Get a DNS-encoded BEP44 record set from the DHT
parameters:
- name: id
in: path
Expand Down Expand Up @@ -49,9 +49,9 @@ paths:
type: string
put:
tags:
- Pkarr Relay
summary: Put a Pkarr record set into the DHT
description: Put a Pkarr record set into the DHT
- DHT
summary: Put DNS-encoded BEP44 records into the DHT
description: Put a DNS-encoded BEP44 record set into the DHT
parameters:
- name: id
in: path
Expand Down Expand Up @@ -97,7 +97,7 @@ paths:
schema:
type: string
requestBody:
description: A deconstructed Pkarr request object
description: A deconstructed DNS-encoded BEP44 request object
content:
application/json:
schema:
Expand Down Expand Up @@ -170,9 +170,9 @@ paths:
did:
type: object
description: "The DID Document."
pkarr:
dht:
type: string
description: "An unpadded base64URL-encoded representation of a full Pkarr payload, represented as 64 bytes sig, 8 bytes u64 big-endian seq, 0-1000 bytes of v concatenated; enabling independent verification."
description: "An unpadded base64URL-encoded representation of a full DNS-encoded BEP44 payload, represented as 64 bytes sig, 8 bytes u64 big-endian seq, 0-1000 bytes of v concatenated; enabling independent verification."
types:
type: array
items:
Expand All @@ -183,7 +183,7 @@ paths:
items:
type: integer
description: "The sequence numbers available for querying for this node."
required: [ did, pkarr ]
required: [ did, dht ]
"400":
description: Invalid request.
content:
Expand Down
Loading
Loading