• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vocdoni / vocdoni-node / 6863543637

14 Nov 2023 12:18PM UTC coverage: 61.774% (+0.1%) from 61.668%
6863543637

Pull #1137

github

altergui
ipfs: refactor removing very old clutter and abstractions

* data.Storage.Init now needs no args
* move DataMockTest into its own package datamock
* assert at compile time that datamock.DataMockTest and ipfs.Handler satisfy data.Storage
* move fsrepo.IsInitialized check into startNode
* remove ancient abstraction types.DataStore
* fixup "ipfs: add EnableLocalDiscovery option": move field EnableLocalDiscovery into ipfs.Handler
Pull Request #1137: feat/ipfs refactor

42 of 45 new or added lines in 7 files covered. (93.33%)

4 existing lines in 2 files now uncovered.

14625 of 23675 relevant lines covered (61.77%)

31034.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/service/ipfs.go
1
package service
2

3
import (
4
        "os"
5
        "time"
6

7
        "go.vocdoni.io/dvote/config"
8
        "go.vocdoni.io/dvote/data"
9
        "go.vocdoni.io/dvote/data/ipfs"
10
        "go.vocdoni.io/dvote/data/ipfs/ipfsconnect"
11
        "go.vocdoni.io/dvote/log"
12
)
13

14
// IPFS starts the IPFS service
15
func IPFS(ipfsconfig *config.IPFSCfg) (storage data.Storage, err error) {
2✔
16
        log.Info("creating ipfs service")
2✔
17
        os.Setenv("IPFS_FD_MAX", "1024")
2✔
18

2✔
19
        ipfsStore := ipfs.New()
2✔
20
        ipfsStore.DataDir = ipfsconfig.ConfigPath
2✔
21
        ipfsStore.EnableLocalDiscovery = ipfsconfig.LocalDiscovery
2✔
22
        err = ipfsStore.Init()
2✔
23
        if err != nil {
2✔
NEW
24
                return nil, err
×
25
        }
×
26
        storage = ipfsStore
2✔
27

2✔
28
        go func() {
4✔
29
                for {
6✔
30
                        time.Sleep(time.Second * 120)
4✔
31
                        log.Monitor("ipfs storage", storage.Stats())
4✔
32
                }
4✔
33
        }()
34

35
        if len(ipfsconfig.ConnectKey) > 0 {
2✔
36
                log.Infow("starting ipfsconnect service", "key", ipfsconfig.ConnectKey)
×
37
                ipfsconn := ipfsconnect.New(
×
38
                        ipfsconfig.ConnectKey,
×
39
                        storage.(*ipfs.Handler),
×
40
                )
×
41
                if len(ipfsconfig.ConnectPeers) > 0 && len(ipfsconfig.ConnectPeers[0]) > 8 {
×
42
                        log.Debugf("using custom ipfsconnect bootnodes %s", ipfsconfig.ConnectPeers)
×
43
                        ipfsconn.Transport.BootNodes = ipfsconfig.ConnectPeers
×
44
                }
×
45
                ipfsconn.Start()
×
46
        }
47
        return storage, nil
2✔
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc