tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit eaba10a6c12470b30090d0c9e39e68728316f72d
parent 9ccd7d978c8cd941c256558a0604e173bcefadf8
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  7 Dec 2017 23:02:56 +0100

Become two seconds faster in fetching a descriptor

Diffstat:
Mgo/lib/helpers.go | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/go/lib/helpers.go b/go/lib/helpers.go @@ -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.