Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Fix Infinite Loop & Misspelling
Browse files Browse the repository at this point in the history
  • Loading branch information
alecbcs committed Jun 9, 2021
1 parent 3a0d377 commit 2dd65d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cli/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type UpArgs struct {
}

type UpFlags struct {
Forground bool `short:"f" long:"forground" desc:"Don't Create Background Daemon."`
Foreground bool `short:"f" long:"foreground" desc:"Don't Create Background Daemon."`
}

func UpRun(r *cmd.Root, c *cmd.Sub) {
Expand All @@ -65,7 +65,7 @@ func UpRun(r *cmd.Root, c *cmd.Sub) {
Global, err := config.Read(configPath)
checkErr(err)

if !flags.Forground {
if !flags.Foreground {
// Make results chan
out := make(chan bool)
go createDaemon(out)
Expand Down Expand Up @@ -163,7 +163,7 @@ func createDaemon(out chan<- bool) {
// Create Sub Process
process, err := os.StartProcess(
path,
append(os.Args, "--forground"),
append(os.Args, "--foreground"),
&os.ProcAttr{
Files: []*os.File{nil, w, nil},
},
Expand All @@ -184,7 +184,7 @@ func createDaemon(out chan<- bool) {
func streamHandler(stream network.Stream) {
// If the remote node ID isn't in the list of known nodes don't respond.
if _, ok := RevLookup[stream.Conn().RemotePeer().Pretty()]; !ok {
stream.Close()
stream.Reset()
}
io.Copy(iface.ReadWriteCloser, stream)
stream.Close()
Expand All @@ -195,7 +195,7 @@ func prettyDiscovery(ctx context.Context, node host.Host, peerTable map[string]p
for ip, id := range peerTable {
tempTable[ip] = id
}
for len(peerTable) > 0 {
for len(tempTable) > 0 {
for ip, id := range tempTable {
stream, err := node.NewStream(ctx, id, p2p.Protocol)
if err != nil && (strings.HasPrefix(err.Error(), "failed to dial") ||
Expand Down
5 changes: 5 additions & 0 deletions p2p/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (

const Protocol = "/hyprspace/0.0.1"

type Packet struct {
Plen int
Data []byte
}

func CreateNode(ctx context.Context, inputKey string, handler network.StreamHandler) (node host.Host, dhtOut *dht.IpfsDHT, err error) {
// Unmarshall Private Key
privateKey, err := crypto.UnmarshalPrivateKey([]byte(inputKey))
Expand Down

0 comments on commit 2dd65d8

Please sign in to comment.