namesys: discard records with invalid EOL in record selection
License: MIT Signed-off-by: Dirk McCormick <dirkmdev@gmail.com>
Dirk McCormick committed
Feb 7, 2018 at 15:48 UTC
7b99538f3ca40302b14bea0319ef6624f1959a6c
1 file changed
+6
-12
namesys/selector.go
+6
-12
@@ -35,23 +35,17 @@ func selectRecord(recs []*pb.IpnsEntry, vals [][]byte) (int, error) {
35
if r == nil || r.GetSequence() < bestSeq {
36
continue
37
}
38
+ rt, err := u.ParseRFC3339(string(r.GetValidity()))
39
+ if err != nil {
40
+ log.Errorf("failed to parse ipns record EOL %s", r.GetValidity())
41
+ continue
42
+ }
43
44
if besti == -1 || r.GetSequence() > bestSeq {
45
bestSeq = r.GetSequence()
46
besti = i
47
} else if r.GetSequence() == bestSeq {
43
- rt, err := u.ParseRFC3339(string(r.GetValidity()))
44
- if err != nil {
45
- log.Errorf("failed to parse ipns record EOL %s", r.GetValidity())
46
- continue
47
- }
48
-
49
- bestt, err := u.ParseRFC3339(string(recs[besti].GetValidity()))
50
- if err != nil {
51
- log.Errorf("failed to parse ipns record EOL %s", recs[besti].GetValidity())
52
- continue
53
- }
54
-
48
+ bestt, _ := u.ParseRFC3339(string(recs[besti].GetValidity()))
49
if rt.After(bestt) {
50
besti = i
51
} else if rt == bestt {