github.com/codingfuture/orig-energi3@v0.8.4/swarm/storage/localstore/doc.go (about)

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