diff --git a/core/core.go b/core/core.go index 5ceacab92..a68cd2d3d 100644 --- a/core/core.go +++ b/core/core.go @@ -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?)")