From e867da64c7bb9ba00fe92085875a887a309c81a9 Mon Sep 17 00:00:00 2001 From: Alex Yu Date: Fri, 5 Apr 2019 12:01:56 +0300 Subject: [PATCH] Merged with mainnet --- Makefile | 19 ++++++++++++++++--- cmd/skywire-cli/commands/tpdisc/root.go | 2 +- pkg/messaging/client.go | 1 + pkg/transport/handshake.go | 1 - pkg/transport/manager.go | 8 ++++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index bb8253ef70..ed67d1a0c1 100644 --- a/Makefile +++ b/Makefile @@ -18,13 +18,13 @@ check: lint test ## Run linters and tests build: dep host-apps bin ## Install dependencies, build apps and binaries. `go build` with ${OPTS} run: stop build config ## Run skywire-node on host - ./skywire-node + ./skywire-node skywire.json stop: ## Stop running skywire-node on host -bash -c "kill $$(ps aux |grep '[s]kywire-node' |awk '{print $$2}')" config: ## Generate skywire.json - -./skywire-cli gen-config -o ./skywire.json -r + -./skywire-cli node gen-config -o ./skywire.json -r clean: ## Clean project: remove created binaries and apps -rm -rf ./apps @@ -33,6 +33,12 @@ clean: ## Clean project: remove created binaries and apps install: ## Install `skywire-node`, `skywire-cli`, `manager-node`, `therealssh-cli` ${OPTS} go install ./cmd/skywire-node ./cmd/skywire-cli ./cmd/manager-node ./cmd/therealssh-cli +rerun: stop + ${OPTS} go build -race -o ./skywire-node ./cmd/skywire-node + -./skywire-cli node gen-config -o ./skywire.json -r + perl -pi -e 's/localhost//g' ./skywire.json + ./skywire-node skywire.json + lint: ## Run linters. Use make install-linters first ${OPTS} golangci-lint run -c .golangci.yml ./... @@ -138,7 +144,8 @@ docker-bin: ## Build `skywire-node`, `skywire-cli`, `manager-node`, `therealssh- ${DOCKER_OPTS} go build -race -o ./node/skywire-node ./cmd/skywire-node docker-volume: docker-apps docker-bin bin ## Prepare docker volume for dockerized skywire-node - -./skywire-cli gen-config -o ./node/skywire.json + -./skywire-cli node gen-config -o ./node/skywire.json -r + perl -pi -e 's/localhost//g' ./node/skywire.json # To make node accessible from outside with skywire-cli docker-run: docker-clean docker-image docker-network docker-volume ## Run dockerized skywire-node ${DOCKER_NODE} in image ${DOCKER_IMAGE} with network ${DOCKER_NETWORK} docker run -it -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} \ @@ -147,6 +154,12 @@ docker-run: docker-clean docker-image docker-network docker-volume ## Run docker docker-stop: ## Stop running dockerized skywire-node ${DOCKER_NODE} -docker container stop ${DOCKER_NODE} +docker-rerun: docker-stop + -./skywire-cli gen-config -o ./node/skywire.json -r + perl -pi -e 's/localhost//g' ./node/skywire.json # To make node accessible from outside with skywire-cli + ${DOCKER_OPTS} go build -race -o ./node/skywire-node ./cmd/skywire-node + docker container start -i ${DOCKER_NODE} + help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/cmd/skywire-cli/commands/tpdisc/root.go b/cmd/skywire-cli/commands/tpdisc/root.go index e0fb6399df..d72036e914 100644 --- a/cmd/skywire-cli/commands/tpdisc/root.go +++ b/cmd/skywire-cli/commands/tpdisc/root.go @@ -70,7 +70,7 @@ func printTransportEntries(entries ...*transport.EntryWithStatus) { internal.Catch(err) for _, e := range entries { _, err := fmt.Fprintf(w, "%s\t%s\t%t\t%d\t%t\t%s\t%s\t%t\t%t\n", - e.Entry.ID, e.Entry.Type, e.Entry.Public, e.Registered, e.IsUp, e.Entry.Edges[0], e.Entry.Edges[1], e.Statuses[0], e.Statuses[1]) + e.Entry.ID, e.Entry.Type, e.Entry.Public, e.Registered, e.IsUp, e.Entry.Edges()[0], e.Entry.Edges()[1], e.Statuses[0], e.Statuses[1]) internal.Catch(err) } internal.Catch(w.Flush()) diff --git a/pkg/messaging/client.go b/pkg/messaging/client.go index 1abb138044..73278339e8 100644 --- a/pkg/messaging/client.go +++ b/pkg/messaging/client.go @@ -144,6 +144,7 @@ func (c *Client) Accept(ctx context.Context) (transport.Transport, error) { func (c *Client) Dial(ctx context.Context, remote cipher.PubKey) (transport.Transport, error) { entry, err := c.dc.Entry(ctx, remote) if err != nil { + fmt.Printf("Dial with remote = %v\n", remote) return nil, fmt.Errorf("get entry failure: %s", err) } diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index 35b8b92310..b82e50ba04 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -16,7 +16,6 @@ func (handshake settlementHandshake) Do(tm *Manager, tr Transport, timeout time. var entry *Entry errCh := make(chan error, 1) go func() { - fmt.Printf("IMMA HERE") e, err := handshake(tm, tr) entry = e errCh <- err diff --git a/pkg/transport/manager.go b/pkg/transport/manager.go index 3d532db5c8..0cd86c3d41 100644 --- a/pkg/transport/manager.go +++ b/pkg/transport/manager.go @@ -3,6 +3,7 @@ package transport import ( "context" "errors" + "fmt" "math/big" "strings" "sync" @@ -347,6 +348,13 @@ func (tm *Manager) createTransport(ctx context.Context, remote cipher.PubKey, tp } func (tm *Manager) dialTransport(ctx context.Context, factory Factory, remote cipher.PubKey, public bool) (Transport, *Entry, error) { + + fmt.Printf("Manager.dialTransport: %v %v\n", tm.Local(), remote) + + if tm.Local() == remote { + fmt.Println("local and remote are equal. No need to dial") + } + tr, err := factory.Dial(ctx, remote) if err != nil { return nil, nil, err