hints: prevent malicious timestamp hints to bork calculations.

This commit is contained in:
fiatjaf
2024-11-28 21:29:47 -03:00
parent 2519cab5ae
commit 9df2fc8d7b
2 changed files with 11 additions and 3 deletions
+4
View File
@@ -27,6 +27,10 @@ func NewHintDB() *HintDB {
}
func (db *HintDB) Save(pubkey string, relay string, key hints.HintKey, ts nostr.Timestamp) {
if now := nostr.Now(); ts > now {
ts = now
}
relayIndex := slices.Index(db.RelayBySerial, relay)
if relayIndex == -1 {
relayIndex = len(db.RelayBySerial)