From 3ba2b0e365652e1e5b275c757c91ac72798e25a0 Mon Sep 17 00:00:00 2001 From: lanzafame Date: Fri, 3 Apr 2020 14:54:07 +1000 Subject: [PATCH 1/3] instead of guessing the address, just use a config value --- node/builder.go | 6 +----- node/config/def.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/node/builder.go b/node/builder.go index 400e936b1..965876691 100644 --- a/node/builder.go +++ b/node/builder.go @@ -16,7 +16,6 @@ import ( pubsub "github.com/libp2p/go-libp2p-pubsub" record "github.com/libp2p/go-libp2p-record" "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr-net" "go.uber.org/fx" "golang.org/x/xerrors" @@ -338,10 +337,7 @@ func ConfigCommon(cfg *config.Common) Option { return lr.SetAPIEndpoint(e) }), Override(new(sectorstorage.URLs), func(e dtypes.APIEndpoint) (sectorstorage.URLs, error) { - _, ip, err := manet.DialArgs(e) - if err != nil { - return nil, xerrors.Errorf("getting api endpoint dial args: %w", err) - } + ip := cfg.API.RemoteListenAddress var urls sectorstorage.URLs urls = append(urls, "http://"+ip+"/remote") // TODO: This makes assumptions, and probably bad ones too diff --git a/node/config/def.go b/node/config/def.go index 483fcf4d0..c6e03eb44 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -2,8 +2,9 @@ package config import ( "encoding" - "github.com/filecoin-project/sector-storage" "time" + + sectorstorage "github.com/filecoin-project/sector-storage" ) // Common is common config between full node and miner @@ -29,8 +30,9 @@ type StorageMiner struct { // API contains configs for API endpoint type API struct { - ListenAddress string - Timeout Duration + ListenAddress string + RemoteListenAddress string + Timeout Duration } // Libp2p contains configs for libp2p @@ -55,8 +57,9 @@ type Metrics struct { func defCommon() Common { return Common{ API: API{ - ListenAddress: "/ip4/127.0.0.1/tcp/1234/http", - Timeout: Duration(30 * time.Second), + ListenAddress: "/ip4/127.0.0.1/tcp/1234/http", + RemoteListenAddress: "127.0.0.1:1234", + Timeout: Duration(30 * time.Second), }, Libp2p: Libp2p{ ListenAddresses: []string{ From 27e81f37f3ea68aa7fbafc02d7bbf7d5c7a43d5b Mon Sep 17 00:00:00 2001 From: lanzafame Date: Fri, 3 Apr 2020 15:01:39 +1000 Subject: [PATCH 2/3] fix todo comment --- node/builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/builder.go b/node/builder.go index 965876691..d12eee363 100644 --- a/node/builder.go +++ b/node/builder.go @@ -340,7 +340,7 @@ func ConfigCommon(cfg *config.Common) Option { ip := cfg.API.RemoteListenAddress var urls sectorstorage.URLs - urls = append(urls, "http://"+ip+"/remote") // TODO: This makes assumptions, and probably bad ones too + urls = append(urls, "http://"+ip+"/remote") // TODO: This makes no assumptions, and probably could... return urls, nil }), ApplyIf(func(s *Settings) bool { return s.Online }, From 209e8b3041e48e911e540985d6526fbb85827c70 Mon Sep 17 00:00:00 2001 From: lanzafame Date: Sat, 4 Apr 2020 09:56:52 +1000 Subject: [PATCH 3/3] only add RemoteListenAddress to StorageMinerNode config --- node/config/def.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/config/def.go b/node/config/def.go index c6e03eb44..f848ce325 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -57,9 +57,8 @@ type Metrics struct { func defCommon() Common { return Common{ API: API{ - ListenAddress: "/ip4/127.0.0.1/tcp/1234/http", - RemoteListenAddress: "127.0.0.1:1234", - Timeout: Duration(30 * time.Second), + ListenAddress: "/ip4/127.0.0.1/tcp/1234/http", + Timeout: Duration(30 * time.Second), }, Libp2p: Libp2p{ ListenAddresses: []string{ @@ -75,7 +74,7 @@ func defCommon() Common { } -// Default returns the default config +// DefaultFullNode returns the default config func DefaultFullNode() *FullNode { return &FullNode{ Common: defCommon(), @@ -93,6 +92,7 @@ func DefaultStorageMiner() *StorageMiner { }, } cfg.Common.API.ListenAddress = "/ip4/127.0.0.1/tcp/2345/http" + cfg.Common.API.RemoteListenAddress = "127.0.0.1:2345" return cfg }