diff --git a/Store.go b/DHT Store.go similarity index 85% rename from Store.go rename to DHT Store.go index 3db056c..b22abf5 100644 --- a/Store.go +++ b/DHT Store.go @@ -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 } diff --git a/Kademlia.go b/Kademlia.go index f8f9d55..1b2101a 100644 --- a/Kademlia.go +++ b/Kademlia.go @@ -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) diff --git a/Transfer Blocks.go b/Transfer Block.go similarity index 96% rename from Transfer Blocks.go rename to Transfer Block.go index fb776c4..400d19d 100644 --- a/Transfer Blocks.go +++ b/Transfer Block.go @@ -1,5 +1,5 @@ /* -File Name: Transfer Blocks.go +File Name: Transfer Block.go Copyright: 2021 Peernet s.r.o. Author: Peter Kleissner */ diff --git a/store/Store.go b/store/Store.go index 3e24d61..08a0e8c 100644 --- a/store/Store.go +++ b/store/Store.go @@ -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