mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
24 lines
427 B
Go
24 lines
427 B
Go
package libp2p
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/libp2p/go-libp2p/core/peerstore"
|
|
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
func Peerstore(lc fx.Lifecycle) (peerstore.Peerstore, error) {
|
|
pstore, err := pstoremem.NewPeerstore()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
lc.Append(fx.Hook{
|
|
OnStop: func(ctx context.Context) error {
|
|
return pstore.Close()
|
|
},
|
|
})
|
|
|
|
return pstore, nil
|
|
}
|