diff --git a/api/client.go b/api/client.go index 02467fe087fd01751aebca1b8aad4f3df72a5fca..82d16af47428fa6326aafa1b6640c816cefcb1c6 100644 --- a/api/client.go +++ b/api/client.go @@ -422,7 +422,10 @@ func (c *Client) StartNetworkFollower(timeout time.Duration) error { u := c.GetUser() jww.INFO.Printf("StartNetworkFollower() \n\tTransmisstionID: %s "+ "\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID) - + err := c.registerFollower() + if err != nil { + return err + } return c.followerServices.start(timeout) } diff --git a/api/services.go b/api/services.go index 54288eada7350254940b53f37c673a3599726b71..d1f3b1ed2a97cd5e478972f320c21c1775836267 100644 --- a/api/services.go +++ b/api/services.go @@ -101,7 +101,7 @@ func (s *services) stop() error { return errors.WithMessage(err, "Failed to stop services") } - s.state = Stopped + //s.state = Stopped return nil } diff --git a/api/user.go b/api/user.go index 2f807265e708cb037fa0986cecd95aecd7ed798d..ef8eb1092ee61e8e766c00d2979cb4c20d108d82 100644 --- a/api/user.go +++ b/api/user.go @@ -40,7 +40,7 @@ func createNewUser(rng *fastRNG.StreamGenerator, cmix, e2e *cyclic.Group) user.U wg.Add(4) - go func(){ + go func() { defer wg.Done() var err error // FIXME: Why 256 bits? -- this is spec but not explained, it has @@ -54,7 +54,7 @@ func createNewUser(rng *fastRNG.StreamGenerator, cmix, e2e *cyclic.Group) user.U } }() - go func(){ + go func() { defer wg.Done() var err error // DH Keygen @@ -183,7 +183,7 @@ func createPrecannedUser(precannedID uint, rng csprng.Source, cmix, e2e *cyclic. } // createNewVanityUser generates an identity for cMix -// The identity's ReceptionID is not random but starts with the supplied prefix +// The identity's ReceptionID is not random but starts with the supplied prefix func createNewVanityUser(rng csprng.Source, cmix, e2e *cyclic.Group, prefix string) user.User { // CMIX Keygen // FIXME: Why 256 bits? -- this is spec but not explained, it has @@ -229,14 +229,14 @@ func createNewVanityUser(rng csprng.Source, cmix, e2e *cyclic.Group, prefix stri } var mu sync.Mutex // just in case more than one go routine tries to access receptionSalt and receptionID - done := make(chan struct{}) - found:= make(chan bool) - wg:= &sync.WaitGroup{} + done := make(chan struct{}) + found := make(chan bool) + wg := &sync.WaitGroup{} cores := runtime.NumCPU() var receptionSalt []byte - var receptionID *id.ID - + var receptionID *id.ID + pref := prefix ignoreCase := false // check if case-insensitivity is enabled @@ -250,13 +250,13 @@ func createNewVanityUser(rng csprng.Source, cmix, e2e *cyclic.Group, prefix stri jww.FATAL.Panicf("Prefix contains non-Base64 characters") } jww.INFO.Printf("Vanity userID generation started. Prefix: %s Ignore-Case: %v NumCPU: %d", pref, ignoreCase, cores) - for w := 0; w < cores; w++{ + for w := 0; w < cores; w++ { wg.Add(1) go func() { rSalt := make([]byte, SaltSize) - for { + for { select { - case <- done: + case <-done: defer wg.Done() return default: @@ -274,7 +274,7 @@ func createNewVanityUser(rng csprng.Source, cmix, e2e *cyclic.Group, prefix stri id := rID.String() if ignoreCase { id = strings.ToLower(id) - } + } if strings.HasPrefix(id, pref) { mu.Lock() receptionID = rID @@ -284,12 +284,12 @@ func createNewVanityUser(rng csprng.Source, cmix, e2e *cyclic.Group, prefix stri defer wg.Done() return } - } + } } }() } // wait for a solution then close the done channel to signal the workers to exit - <- found + <-found close(done) wg.Wait() return user.User{