From 1e23bdb2e023d25e56cc8554a5cead1992e01cf0 Mon Sep 17 00:00:00 2001 From: Alec Scott Date: Sat, 26 Jun 2021 10:33:08 -0700 Subject: [PATCH] Switch to DHTClient Mode & Build Smaller Binaries --- .github/workflows/build.sh | 2 +- go.mod | 1 + p2p/node.go | 6 ++---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index 475ec7d..3ae337f 100644 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -7,6 +7,6 @@ do platform_split=(${platform//\// }) GOOS=${platform_split[0]} GOARCH=${platform_split[1]} - env GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-X github.com/hyprspace/hyprspace/cli.appVersion=$1" -o hyprspace-$1-${GOOS}-${GOARCH} . + env GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/hyprspace/hyprspace/cli.appVersion=$1" -o hyprspace-$1-${GOOS}-${GOARCH} . done \ No newline at end of file diff --git a/go.mod b/go.mod index b521c47..517e6f1 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/DataDrake/cli-ng/v2 v2.0.2 github.com/hashicorp/go-version v1.2.1 // indirect github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf + github.com/ipfs/go-datastore v0.4.5 github.com/kr/text v0.2.0 // indirect github.com/libp2p/go-libp2p v0.14.1 github.com/libp2p/go-libp2p-core v0.8.5 diff --git a/p2p/node.go b/p2p/node.go index 76ae64f..a2747f8 100644 --- a/p2p/node.go +++ b/p2p/node.go @@ -5,6 +5,7 @@ import ( "fmt" "sync" + "github.com/ipfs/go-datastore" "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/host" @@ -38,10 +39,7 @@ func CreateNode(ctx context.Context, inputKey string, port int, handler network. node.SetStreamHandler(Protocol, handler) // Create DHT Subsystem - dhtOut, err = dht.New(ctx, node) - if err != nil { - return - } + dhtOut = dht.NewDHTClient(ctx, node, datastore.NewMapDatastore()) // Define Bootstrap Nodes. peers := []string{