Skip to content

Commit 28b291e

Browse files
cmrbkase
authored andcommitted
Hotfix/friday feedback (#3715)
* turn libp2p discovery on by default now: -discovery-port for the libp2p port -discovery-keypair instead of -libp2p-keypair (generate command doesn't change) -disable-libp2p-discovery to turn it off -enable-old-discovery to turn that back on Discovery keypairs are now comma-separated. It will continue to accept both syntaxes but the semicolon one is prone to errors in shell scripts and was definitely a mistake. * don't include PID in libp2p_helper state dirs * include peer_id in status * tweak high connectivity check * add libp2p_priv_to_pub utility * include node_addrs_and_ports in status * typo * add net2 stub
1 parent 20d8fd8 commit 28b291e

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/codanet.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,13 @@ func MakeHelper(ctx context.Context, listenOn []ma.Multiaddr, externalAddr ma.Mu
6666
logger := logging.Logger("codanet.Helper")
6767
dso := dsb.DefaultOptions
6868

69-
bp := path.Join(statedir, strconv.Itoa(os.Getpid()))
70-
os.MkdirAll(bp, 0700)
71-
72-
ds, err := dsb.NewDatastore(path.Join(statedir, strconv.Itoa(os.Getpid()), "libp2p-peerstore-v0"), &dso)
69+
ds, err := dsb.NewDatastore(path.Join(statedir, "libp2p-peerstore-v0"), &dso)
7370
if err != nil {
7471
return nil, err
7572
}
7673

7774
dsoDht := dsb.DefaultOptions
78-
dsDht, err := dsb.NewDatastore(path.Join(statedir, strconv.Itoa(os.Getpid()), "libp2p-dht-v0"), &dsoDht)
75+
dsDht, err := dsb.NewDatastore(path.Join(statedir, "libp2p-dht-v0"), &dsoDht)
7976
if err != nil {
8077
return nil, err
8178
}

src/gen_keys/libp2p_priv_to_pub.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
import (
3+
crypto "github.com/libp2p/go-libp2p-crypto"
4+
b58 "github.com/mr-tron/base58/base58"
5+
"os"
6+
)
7+
8+
func main() {
9+
if len(os.Args) != 2 {
10+
println("usage: libp2p-priv-to-pub PRIVKEY_BASE58_STRING");
11+
}
12+
privk_enc := os.Args[1]
13+
privk_raw, err := b58.Decode(privk_enc)
14+
if err != nil { panic(err); }
15+
16+
priv, err := crypto.UnmarshalPrivateKey(privk_raw)
17+
if err != nil { panic(err); }
18+
19+
pub := priv.GetPublic()
20+
21+
pubk_raw, err := crypto.MarshalPublicKey(pub)
22+
if err != nil { panic(err); }
23+
24+
pubk_enc := b58.Encode(pubk_raw)
25+
26+
println(pubk_enc)
27+
}

0 commit comments

Comments
 (0)