tBecome two seconds faster in fetching a descriptor - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit eaba10a6c12470b30090d0c9e39e68728316f72d DIR parent 9ccd7d978c8cd941c256558a0604e173bcefadf8 HTML Author: parazyd <parazyd@dyne.org> Date: Thu, 7 Dec 2017 23:02:56 +0100 Become two seconds faster in fetching a descriptor Diffstat: M go/lib/helpers.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- DIR diff --git a/go/lib/helpers.go b/go/lib/helpers.go t@@ -69,19 +69,19 @@ func ValidateReq(req map[string]string) ([]byte, bool) { var cnt = 0 log.Println(req["address"], "seems valid") for { // We try until we have it. - if strings.HasPrefix(pubkey, "-----BEGIN RSA PUBLIC KEY-----") && - strings.HasSuffix(pubkey, "-----END RSA PUBLIC KEY-----") { - log.Println("Got descriptor!") - break - } cnt += 1 if cnt > 10 { // We probably can't get a good HSDir. The client shall retry // later on. return []byte("Couldn't get a descriptor. Try later."), false } - time.Sleep(2000 * time.Millisecond) pubkey = FetchHSPubkey(req["address"]) + if strings.HasPrefix(pubkey, "-----BEGIN RSA PUBLIC KEY-----") && + strings.HasSuffix(pubkey, "-----END RSA PUBLIC KEY-----") { + log.Println("Got descriptor!") + break + } + time.Sleep(2000 * time.Millisecond) } // Validate signature.