| 19 | return it.it.Key() |
| 20 | } |
| 21 | |
| 22 | func (it *Iterator) Value() []byte { |
| 23 | key := it.it.Key() |
| 24 | // Try to get the value from IPFS first for consistency |
| 25 | if it.ipfsDB != nil { |
| 26 | value, err := it.ipfsDB.Get(key) |
| 27 | if err == nil && value != nil { |
| 28 | if it.db.encryptionKey != nil { |
| 29 | if pt, derr := decrypt(value, it.db.encryptionKey); derr == nil { |
| 30 | return pt |
| 31 | } else { |
| 32 | log.Printf("ipfs-synckv: iterator decrypt failed for key %q, falling back to local value: %v", key, derr) |
| 33 | } |
| 34 | // Decrypt failed (corrupt/foreign data): fall through to the local value. |
| 35 | } else { |
| 36 | return value |
| 37 | } |
| 38 | } |