Housekeeping, renaming few things for clarification.

This commit is contained in:
Kleissner
2021-12-08 20:55:17 +01:00
parent 4aa15d6a78
commit c2af2fe5e7
4 changed files with 10 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
File Name: Store.go
File Name: DHT Store.go
Copyright: 2021 Peernet s.r.o.
Author: Peter Kleissner
*/
@@ -11,19 +11,19 @@ import (
"github.com/PeernetOfficial/core/store"
)
// Warehouse contains all key-value data served via DHT
var Warehouse store.Store
// dhtStore contains all key-value data served via DHT
var dhtStore store.Store
// TODO: Via descriptors, files stored by other peers
func initStore() {
Warehouse = store.NewMemoryStore()
dhtStore = store.NewMemoryStore()
}
// announcementGetData returns data for an announcement
func announcementGetData(hash []byte) (stored bool, data []byte) {
// TODO: Create RetrieveIfSize to prevent files larger than EmbeddedFileSizeMax from being loaded
data, found := Warehouse.Get(hash)
data, found := dhtStore.Get(hash)
if !found {
return false, nil
}

View File

@@ -142,7 +142,7 @@ func GetData(hash []byte) (data []byte, senderNodeID []byte, found bool) {
// GetDataLocal returns data from the local warehouse.
func GetDataLocal(hash []byte) (data []byte, found bool) {
return Warehouse.Get(hash)
return dhtStore.Get(hash)
}
// GetDataDHT requests data via DHT
@@ -154,14 +154,14 @@ func GetDataDHT(hash []byte) (data []byte, senderNodeID []byte, found bool) {
// StoreDataLocal stores data into the local warehouse.
func StoreDataLocal(data []byte) error {
key := protocol.HashData(data)
return Warehouse.Set(key, data)
return dhtStore.Set(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 := protocol.HashData(data)
if err := Warehouse.Set(key, data); err != nil {
if err := dhtStore.Set(key, data); err != nil {
return err
}
return nodesDHT.Store(key, uint64(len(data)), closestCount)

View File

@@ -1,5 +1,5 @@
/*
File Name: Transfer Blocks.go
File Name: Transfer Block.go
Copyright: 2021 Peernet s.r.o.
Author: Peter Kleissner
*/

View File

@@ -3,7 +3,7 @@ File Name: Store.go
Copyright: 2021 Peernet s.r.o.
Author: Peter Kleissner
Simple key-value store implementation. Currently in-memory only.
Simple key-value store interface.
*/
package store