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-dms3ns
Commits
fa15ed2e
Unverified
Commit
fa15ed2e
authored
6 years ago
by
Rob Brackett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `Create` example to godoc
License: MIT Signed-off-by:
Rob Brackett
<
rob@robbrackett.com
>
parent
6e1876c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
ipns_test.go
ipns_test.go
+14
-0
No files found.
ipns_test.go
View file @
fa15ed2e
...
...
@@ -41,3 +41,17 @@ func TestEmbedPublicKey(t *testing.T) {
t
.
Fatalf
(
"pid mismatch: %s != %s"
,
pid
,
embeddedPid
)
}
}
func
ExampleCreate
()
{
// Generate a private key to sign the IPNS record with. Most of the time,
// however, you'll want to retrieve an already-existing key from IPFS using
// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
privateKey
,
publicKey
,
err
:=
ic
.
GenerateKeyPair
(
ic
.
RSA
,
2048
)
// Create an IPNS record that expires in one hour and points to the IPFS address
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
ipnsRecord
,
err
:=
Create
(
privateKey
,
[]
byte
(
"/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"
),
0
,
time
.
Now
()
.
Add
(
1
*
time
.
Hour
))
if
err
!=
nil
{
panic
(
err
)
}
}
This diff is collapsed.
Click to expand it.
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