URI: 
       tWrite "firstseen" and "valid" only if the node is not in redis - 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 b86db595deb695358fc2591453f9b1dbea1267b8
   DIR parent fef7f290c2817471b77e212ea8eb7fd0d75f3b26
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Fri,  8 Dec 2017 18:40:09 +0100
       
       Write "firstseen" and "valid" only if the node is not in redis
       
       Diffstat:
         M cmd/dam-dir/main.go                 |      16 ++++++++++------
       
       1 file changed, 10 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/cmd/dam-dir/main.go b/cmd/dam-dir/main.go
       t@@ -99,9 +99,9 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
                        jsonVal, err := json.Marshal(ret)
                        lib.CheckError(err)
        
       -                // TODO: We probably _do_ want to allow the keyholder to
       -                // reannounce itself, so let's not handle this yet.
       -                //ex := RedisCli.Exists(n.Address)
       +                // Check if we have seen this node already.
       +                ex, err := RedisCli.Exists(n.Address).Result()
       +                lib.CheckError(err)
        
                        // Save the node into redis
                        info := map[string]interface{}{
       t@@ -111,11 +111,15 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
                                "signature": n.Signature,
                                "secret":    base64.StdEncoding.EncodeToString([]byte(randString)),
                                "pubkey":    n.Pubkey,
       -                        "firstseen": n.Firstseen,
                                "lastseen":  n.Lastseen,
       -                        "valid":     0, // This should be 1 after the node is not considered malicious
                        }
       -                log.Println("Writing into Redis")
       +
       +                if ex != 1 {
       +                        info["firstseen"] = n.Firstseen
       +                        info["valid"] = 0 // This should be 1 after the node is not considered malicious
       +                }
       +
       +                log.Println("Writing to Redis")
                        redRet, err := RedisCli.HMSet(n.Address, info).Result()
                        lib.CheckError(err)