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-dms3
Commits
7555786e
Unverified
Commit
7555786e
authored
Sep 09, 2019
by
Steven Allen
Committed by
GitHub
Sep 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6629 from ipfs/feat/close-peerstore
fix: close peerstore on stop
parents
3cbd1633
9f1f9584
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
core/node/groups.go
core/node/groups.go
+2
-3
core/node/libp2p/peerstore.go
core/node/libp2p/peerstore.go
+20
-0
No files found.
core/node/groups.go
View file @
7555786e
...
...
@@ -10,7 +10,6 @@ import (
"github.com/ipfs/go-ipfs-config"
util
"github.com/ipfs/go-ipfs-util"
peer
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
pubsub
"github.com/libp2p/go-libp2p-pubsub"
"github.com/ipfs/go-ipfs/core/node/libp2p"
...
...
@@ -161,7 +160,7 @@ func Identity(cfg *config.Config) fx.Option {
if
cfg
.
Identity
.
PrivKey
==
""
{
return
fx
.
Options
(
// No PK (usually in tests)
fx
.
Provide
(
PeerID
(
id
)),
fx
.
Provide
(
pstoremem
.
New
Peerstore
),
fx
.
Provide
(
libp2p
.
Peerstore
),
)
}
...
...
@@ -173,7 +172,7 @@ func Identity(cfg *config.Config) fx.Option {
return
fx
.
Options
(
// Full identity
fx
.
Provide
(
PeerID
(
id
)),
fx
.
Provide
(
PrivateKey
(
sk
)),
fx
.
Provide
(
pstoremem
.
New
Peerstore
),
fx
.
Provide
(
libp2p
.
Peerstore
),
fx
.
Invoke
(
libp2p
.
PstoreAddSelfKeys
),
)
...
...
core/node/libp2p/peerstore.go
0 → 100644
View file @
7555786e
package
libp2p
import
(
"context"
"github.com/libp2p/go-libp2p-core/peerstore"
"github.com/libp2p/go-libp2p-peerstore/pstoremem"
"go.uber.org/fx"
)
func
Peerstore
(
lc
fx
.
Lifecycle
)
peerstore
.
Peerstore
{
pstore
:=
pstoremem
.
NewPeerstore
()
lc
.
Append
(
fx
.
Hook
{
OnStop
:
func
(
ctx
context
.
Context
)
error
{
return
pstore
.
Close
()
},
})
return
pstore
}
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