github.com/deroproject/derosuite@v2.1.6-1.0.20200307070847-0f2e589c7a2b+incompatible/storage/interface.go (about) 1 // Copyright 2017-2018 DERO Project. All rights reserved. 2 // Use of this source code in any form is governed by RESEARCH license. 3 // license can be found in the LICENSE file. 4 // GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8 5 // 6 // 7 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 8 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 9 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 10 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 12 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 13 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 14 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 15 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 17 package storage 18 19 /*type DB struct { 20 TX interface{} // actual TX object 21 }*/ 22 23 // complete transactional support for improved reliability 24 // TODO do we need to support isolation level ????? 25 type DBTX interface { 26 27 // Begin(bool) // whether to create a writable tx or readable tx 28 Commit() error // commit all writes persistantly 29 Rollback() // Rollback all changes since last commit 30 Sync() // sync the data 31 32 StoreObject(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte, data []byte) error // store object to a specific universe 33 LoadObject(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte) ([]byte, error) // load object from a specific universe 34 35 // LoadObjects(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte) ([][]byte, [][]byte, error) // load all key values for specific bucket 36 37 StoreUint64(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte, data uint64) error // store 38 LoadUint64(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte) (uint64, error) // load object 39 // CreateBucket(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte) error // creates an object bucket 40 41 } 42 43 type Store interface { 44 Init(param map[string]interface{}) error // init the backend and connect to it 45 Shutdown() error // shutdown the backend 46 47 BeginTX(bool) (DBTX, error) // actual TX object to interact with DB 48 /* 49 Commit() // commit all writes persistantly 50 Rollback() // Rollback all changes since last commit 51 Sync() // sync the data 52 53 StoreObject(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte, data []byte) error // store object to a specific universe 54 LoadObject(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte) ([]byte, error) // load object from a specific universe 55 56 LoadObjects(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte) ([][]byte, [][]byte, error) // load all key values for specific bucket 57 58 StoreUint64(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte, data uint64) error // store 59 LoadUint64(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte, key []byte) (uint64, error) // load object 60 CreateBucket(universe_bucket []byte, galaxy_bucket []byte, solar_bucket []byte) error // creates an object bucket 61 */ 62 } 63 64 //var Store Backend_Store// the system shouls chooose a backend at start Time