1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 19:24:14 +08:00

add online method to node

This commit is contained in:
Brian Tiger Chow
2014-11-06 03:37:39 -08:00
committed by Juan Batiz-Benet
parent e096060b90
commit 772f657fcd

View File

@ -74,6 +74,8 @@ type IpfsNode struct {
Pinning pin.Pinner
ctxc.ContextCloser
online bool // alternatively, offline
}
// NewIpfsNode constructs a new IpfsNode based on the given config.
@ -92,6 +94,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// derive this from a higher context.
ctx := context.TODO()
n = &IpfsNode{
online: online,
Config: cfg,
ContextCloser: ctxc.NewContextCloser(ctx, nil),
}
@ -172,6 +175,10 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
return n, nil
}
func (n *IpfsNode) Online() bool {
return n.online
}
func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) {
if cfg.Identity.PeerID == "" {
return nil, errors.New("Identity was not set in config (was ipfs init run?)")