Skip to content

Commit

Permalink
namesys: discard records with invalid EOL in record selection
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Dirk McCormick <[email protected]>
  • Loading branch information
dirkmc committed Feb 7, 2018
1 parent a584eb0 commit b3636de
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions namesys/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@ func selectRecord(recs []*pb.IpnsEntry, vals [][]byte) (int, error) {
if r == nil || r.GetSequence() < bestSeq {
continue
}
rt, err := u.ParseRFC3339(string(r.GetValidity()))
if err != nil {
log.Errorf("failed to parse ipns record EOL %s", r.GetValidity())
continue
}

if besti == -1 || r.GetSequence() > bestSeq {
bestSeq = r.GetSequence()
besti = i
} else if r.GetSequence() == bestSeq {
rt, err := u.ParseRFC3339(string(r.GetValidity()))
if err != nil {
log.Errorf("failed to parse ipns record EOL %s", r.GetValidity())
continue
}

bestt, err := u.ParseRFC3339(string(recs[besti].GetValidity()))
if err != nil {
log.Errorf("failed to parse ipns record EOL %s", recs[besti].GetValidity())
continue
}

bestt, _ := u.ParseRFC3339(string(recs[besti].GetValidity()))
if rt.After(bestt) {
besti = i
} else if rt == bestt {
Expand Down

0 comments on commit b3636de

Please sign in to comment.