aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/database.go
diff options
context:
space:
mode:
authorDmitrij Koniajev <dimchansky@gmail.com>2018-10-16 06:47:25 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-10-16 06:47:25 +0800
commit6a7695e3676ef8275afd5eafde6e045b7a7ab024 (patch)
treedc780ccb960c9ef7c82c3a50af353e224d869633 /ethdb/database.go
parent16e4d0e0055f7fce620ff6881a1393d955c06cee (diff)
downloadgo-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar.gz
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar.bz2
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar.lz
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar.xz
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.tar.zst
go-tangerine-6a7695e3676ef8275afd5eafde6e045b7a7ab024.zip
ethdb, rpc: support building on js/wasm (#17709)
The changes allow building WebAssembly applications which use ethclient.Client.
Diffstat (limited to 'ethdb/database.go')
-rw-r--r--ethdb/database.go70
1 files changed, 2 insertions, 68 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index 99abd09b9..6c62d6a38 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -14,6 +14,8 @@
// 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/>.
+// +build !js
+
package ethdb
import (
@@ -380,71 +382,3 @@ func (b *ldbBatch) Reset() {
b.b.Reset()
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()
-}