Skip to content

Conversation

@altergui
Copy link
Contributor

@altergui altergui commented Oct 9, 2023

  • ipfs: add EnableLocalDiscovery option
  • ipfs: refactor removing very old clutter and abstractions

@altergui altergui marked this pull request as draft October 9, 2023 16:04
@altergui
Copy link
Contributor Author

altergui commented Oct 9, 2023

our current way of initializing IPFS is absolutely convoluted, so i'm working towards a simplification (WIP)

right now, this is a code snippet used by census3 for example

	ipfsConfig := storagelayer.IPFSNewConfig(dataDir)
	storage, err := storagelayer.Init(storagelayer.IPFS, ipfsConfig)
	if err != nil {
		return nil, ErrInitializingIPFS
	}
	var ipfsConn *ipfsconnect.IPFSConnect
	if len(groupKey) > 0 {
		ipfsConn = ipfsconnect.New(groupKey, storage.(*ipfs.Handler))
		ipfsConn.Start()
	}

which doesn't look terrible, but: passing a new option (besides dataDir) is almost impossible

i believe it would make much more sense to end up with something like this:

	storage, err := storagelayer.NewIPFS(config.IPFSCfg{
		ConfigPath: dataDir,
		ConnectKey: groupKey,
	})
	if err != nil {
		return nil, ErrInitializingIPFS
	}

that would also allow me to add options through IPFSCfg, much more easily

@altergui altergui linked an issue Oct 17, 2023 that may be closed by this pull request
@altergui altergui self-assigned this Oct 18, 2023
* 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
@altergui
Copy link
Contributor Author

here's more progress but still there's a lot of duplication that i want to remove
in some way, i'm rounding up the refactor done 6 months ago in af85c05

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6863543637

  • 42 of 45 (93.33%) changed or added relevant lines in 7 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.1%) to 61.774%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/ipfs.go 8 9 88.89%
data/ipfs/init.go 18 20 90.0%
Files with Coverage Reduction New Missed Lines %
data/ipfs/ipfs.go 2 53.18%
vochain/indexer/archive.go 2 76.7%
Totals Coverage Status
Change from base Build 6851529453: 0.1%
Covered Lines: 14625
Relevant Lines: 23675

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ipfsconnect is not working properly

3 participants