|
@@ -14,6 +14,8 @@
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
+// +build !js
|
|
|
|
|
+
|
|
|
package ethdb
|
|
package ethdb
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
@@ -380,71 +382,3 @@ func (b *ldbBatch) Reset() {
|
|
|
b.b.Reset()
|
|
b.b.Reset()
|
|
|
b.size = 0
|
|
b.size = 0
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-type table struct {
|
|
|
|
|
- db Database
|
|
|
|
|
- prefix string
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// NewTable returns a Database object that prefixes all keys with a given
|
|
|
|
|
-// string.
|
|
|
|
|
-func NewTable(db Database, prefix string) Database {
|
|
|
|
|
- return &table{
|
|
|
|
|
- db: db,
|
|
|
|
|
- prefix: prefix,
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) Put(key []byte, value []byte) error {
|
|
|
|
|
- return dt.db.Put(append([]byte(dt.prefix), key...), value)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) Has(key []byte) (bool, error) {
|
|
|
|
|
- return dt.db.Has(append([]byte(dt.prefix), key...))
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) Get(key []byte) ([]byte, error) {
|
|
|
|
|
- return dt.db.Get(append([]byte(dt.prefix), key...))
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) Delete(key []byte) error {
|
|
|
|
|
- return dt.db.Delete(append([]byte(dt.prefix), key...))
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) Close() {
|
|
|
|
|
- // Do nothing; don't close the underlying DB.
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-type tableBatch struct {
|
|
|
|
|
- batch Batch
|
|
|
|
|
- prefix string
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// NewTableBatch returns a Batch object which prefixes all keys with a given string.
|
|
|
|
|
-func NewTableBatch(db Database, prefix string) Batch {
|
|
|
|
|
- return &tableBatch{db.NewBatch(), prefix}
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (dt *table) NewBatch() Batch {
|
|
|
|
|
- return &tableBatch{dt.db.NewBatch(), dt.prefix}
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (tb *tableBatch) Put(key, value []byte) error {
|
|
|
|
|
- return tb.batch.Put(append([]byte(tb.prefix), key...), value)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (tb *tableBatch) Delete(key []byte) error {
|
|
|
|
|
- return tb.batch.Delete(append([]byte(tb.prefix), key...))
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (tb *tableBatch) Write() error {
|
|
|
|
|
- return tb.batch.Write()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (tb *tableBatch) ValueSize() int {
|
|
|
|
|
- return tb.batch.ValueSize()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-func (tb *tableBatch) Reset() {
|
|
|
|
|
- tb.batch.Reset()
|
|
|
|
|
-}
|
|
|