@cryptotaxi247 / kubo / commits / 772f657fc

add online method to node

Brian Tiger Chow committed Nov 6, 2014 at 03:37 UTC 772f657fcd348a1980ce37501bcc573b4d48a32e
1 file changed +7
core/core.go
+7
@@ -74,6 +74,8 @@ type IpfsNode struct {
74 Pinning pin.Pinner
75
76 ctxc.ContextCloser
77 +
78 + online bool // alternatively, offline
79 }
80
81 // 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) {
94 // derive this from a higher context.
95 ctx := context.TODO()
96 n = &IpfsNode{
97 + online: online,
98 Config: cfg,
99 ContextCloser: ctxc.NewContextCloser(ctx, nil),
100 }
@@ -172,6 +175,10 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
175 return n, nil
176 }
177
178 +func (n *IpfsNode) Online() bool {
179 + return n.online
180 +}
181 +
182 func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) {
183 if cfg.Identity.PeerID == "" {
184 return nil, errors.New("Identity was not set in config (was ipfs init run?)")