This is an automated email from the ASF dual-hosted git repository.
smihaylov pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git
The following commit(s) were added to refs/heads/develop by this push:
new 3dac89c Update the IPFS bootstrap node and nodeconnector cleanup
3dac89c is described below
commit 3dac89c561f2dd7198f46a9166431056d628416d
Author: Stanislav Mihaylov <[email protected]>
AuthorDate: Thu Sep 5 12:12:15 2019 +0300
Update the IPFS bootstrap node and nodeconnector cleanup
---
libs/ipfs/nodeconnector.go | 13 ++++++++-----
pkg/config/default.go | 8 +++-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/libs/ipfs/nodeconnector.go b/libs/ipfs/nodeconnector.go
index 30c138b..d3d15e0 100644
--- a/libs/ipfs/nodeconnector.go
+++ b/libs/ipfs/nodeconnector.go
@@ -109,9 +109,9 @@ func NewNodeConnector(options ...NodeConnectorOption)
(Connector, error) {
conf.Routing.Type = "dht"
conf.Swarm.ConnMgr = cfg.ConnMgr{
Type: "basic",
- LowWater: 600,
- HighWater: 900,
- GracePeriod: "20s",
+ LowWater: 20,
+ HighWater: 100,
+ GracePeriod: "30s",
}
appRepo := &repo.Mock{
@@ -142,7 +142,9 @@ func NewNodeConnector(options ...NodeConnectorOption)
(Connector, error) {
// Add adds a data to the IPFS network and returns the ipfs path
func (c *NodeConnector) Add(data []byte) (string, error) {
- r, err := c.api.Unixfs().Add(c.ctx, files.NewBytesFile(data))
+ f := files.NewBytesFile(data)
+ defer f.Close()
+ r, err := c.api.Unixfs().Add(c.ctx, f)
if err != nil {
return "", err
}
@@ -157,11 +159,13 @@ func (c *NodeConnector) Get(ipfsPath string) ([]byte,
error) {
if err != nil {
return nil, err
}
+ defer node.Close()
f := files.ToFile(node)
if f == nil {
return nil, errors.New("not a file")
}
+ defer f.Close()
b, err := ioutil.ReadAll(f)
if err != nil {
@@ -169,7 +173,6 @@ func (c *NodeConnector) Get(ipfsPath string) ([]byte,
error) {
}
// TODO: Pin the document
-
return b, nil
}
diff --git a/pkg/config/default.go b/pkg/config/default.go
index 2bc05e7..1ea3ba1 100644
--- a/pkg/config/default.go
+++ b/pkg/config/default.go
@@ -17,10 +17,6 @@
package config
-import (
- ipfsCfg "github.com/ipfs/go-ipfs-config"
-)
-
// DefaultConfig -
func DefaultConfig() *Config {
return &Config{
@@ -54,7 +50,9 @@ func defaultLogConfig() LogConfig {
// IPFSConfig -
func defaultIPFSConfig() IPFSConfig {
return IPFSConfig{
- Bootstrap: ipfsCfg.DefaultBootstrapAddresses,
+ Bootstrap: []string{
+
"/ip4/34.252.47.231/tcp/4001/ipfs/QmcEPkctfqQs6vbvTD8EdJmzy4zouAtrV8AwjLbGhbURep",
+ },
Connector: "embedded",
ListenAddress: "/ip4/0.0.0.0/tcp/4001",
APIAddress: "http://localhost:5001",