Simplify Store interface. Remove unused replication placeholder and untangle expiration option.

MemoryStore is refactored into separate file.
This commit is contained in:
Kleissner
2021-08-11 20:15:22 +02:00
parent 2937154c8d
commit d87e43cd32
3 changed files with 84 additions and 82 deletions

View File

@@ -153,14 +153,14 @@ func GetDataDHT(hash []byte) (data []byte, senderNodeID []byte, found bool) {
// StoreDataLocal stores data into the local warehouse.
func StoreDataLocal(data []byte) error {
key := hashData(data)
return Warehouse.Store(key, data, time.Time{}, time.Time{})
return Warehouse.Store(key, data)
}
// StoreDataDHT stores data locally and informs closestCount peers in the DHT about it.
// Remote peers may choose to keep a record (in case another peers asks) or mirror the full data.
func StoreDataDHT(data []byte, closestCount int) error {
key := hashData(data)
if err := Warehouse.Store(key, data, time.Time{}, time.Time{}); err != nil {
if err := Warehouse.Store(key, data); err != nil {
return err
}
return nodesDHT.Store(key, uint64(len(data)), closestCount)