Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-namesys
Commits
f16eb589
Unverified
Commit
f16eb589
authored
May 07, 2021
by
Ian Davis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fixup tests and ensure go vet and staticcheck pass
parent
2454122e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
4 deletions
+14
-4
dns_test.go
dns_test.go
+0
-1
namesys_test.go
namesys_test.go
+1
-1
publisher.go
publisher.go
+11
-1
publisher_test.go
publisher_test.go
+2
-1
No files found.
dns_test.go
View file @
f16eb589
...
...
@@ -21,7 +21,6 @@ func (m *mockDNS) lookupTXT(ctx context.Context, name string) (txt []string, err
}
func
TestDnsEntryParsing
(
t
*
testing
.
T
)
{
goodEntries
:=
[]
string
{
"QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD"
,
"dnslink=/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD"
,
...
...
namesys_test.go
View file @
f16eb589
...
...
@@ -160,7 +160,7 @@ func TestPublishWithTTL(t *testing.T) {
ttl
:=
1
*
time
.
Second
eol
:=
time
.
Now
()
.
Add
(
2
*
time
.
Second
)
ctx
:=
c
ontext
.
With
Value
(
context
.
Background
(),
"ipns-publish-ttl"
,
ttl
)
ctx
:=
C
ontextWith
TTL
(
context
.
Background
(),
ttl
)
err
=
nsys
.
Publish
(
ctx
,
priv
,
p
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
publisher.go
View file @
f16eb589
...
...
@@ -206,7 +206,7 @@ func (p *IpnsPublisher) PublishWithEOL(ctx context.Context, k ci.PrivKey, value
// as such, i'm using the context to wire it through to avoid changing too
// much code along the way.
func
checkCtxTTL
(
ctx
context
.
Context
)
(
time
.
Duration
,
bool
)
{
v
:=
ctx
.
Value
(
"ipns-publish-ttl"
)
v
:=
ctx
.
Value
(
ttlContextKey
)
if
v
==
nil
{
return
0
,
false
}
...
...
@@ -296,3 +296,13 @@ func PublishEntry(ctx context.Context, r routing.ValueStore, ipnskey string, rec
func
PkKeyForID
(
id
peer
.
ID
)
string
{
return
"/pk/"
+
string
(
id
)
}
// contextKey is a private comparable type used to hold value keys in contexts
type
contextKey
string
var
ttlContextKey
contextKey
=
"ipns-publish-ttl"
// ContextWithTTL returns a copy of the parent context with an added value representing the TTL
func
ContextWithTTL
(
ctx
context
.
Context
,
ttl
time
.
Duration
)
context
.
Context
{
return
context
.
WithValue
(
context
.
Background
(),
ttlContextKey
,
ttl
)
}
publisher_test.go
View file @
f16eb589
...
...
@@ -3,10 +3,11 @@ package namesys
import
(
"context"
"crypto/rand"
"github.com/ipfs/go-path"
"testing"
"time"
"github.com/ipfs/go-path"
ds
"github.com/ipfs/go-datastore"
dssync
"github.com/ipfs/go-datastore/sync"
dshelp
"github.com/ipfs/go-ipfs-ds-help"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment