github.com/susy-go/susy-graviton@v0.0.0-20190614130430-36cddae42305/swarm/storage/localstore/doc.go (about) 1 // Copyleft 2019 The susy-graviton Authors 2 // This file is part of the susy-graviton library. 3 // 4 // The susy-graviton library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The susy-graviton library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MSRCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the susy-graviton library. If not, see <http://www.gnu.org/licenses/>. 16 17 /* 18 Package localstore provides disk storage layer for Swarm Chunk persistence. 19 It uses swarm/shed abstractions on top of github.com/syndtr/goleveldb LevelDB 20 implementation. 21 22 The main type is DB which manages the storage by providing methods to 23 access and add Chunks and to manage their status. 24 25 Modes are abstractions that do specific changes to Chunks. There are three 26 mode types: 27 28 - ModeGet, for Chunk access 29 - ModePut, for adding Chunks to the database 30 - ModeSet, for changing Chunk statuses 31 32 Every mode type has a corresponding type (Getter, Putter and Setter) 33 that provides adequate method to perform the opperation and that type 34 should be injected into localstore consumers instead the whole DB. 35 This provides more clear insight which operations consumer is performing 36 on the database. 37 38 Getters, Putters and Setters accept different get, put and set modes 39 to perform different actions. For example, ModeGet has two different 40 variables ModeGetRequest and ModeGetSync and two different Getters 41 can be constructed with them that are used when the chunk is requested 42 or when the chunk is synced as this two events are differently changing 43 the database. 44 45 Subscription methods are implemented for a specific purpose of 46 continuous iterations over Chunks that should be provided to 47 Push and Pull syncing. 48 49 DB implements an internal garbage collector that removes only synced 50 Chunks from the database based on their most recent access time. 51 52 Internally, DB stores Chunk data and any required information, such as 53 store and access timestamps in different shed indexes that can be 54 iterated on by garbage collector or subscriptions. 55 */ 56 package localstore