diff options
Diffstat (limited to 'ethdb/database.go')
-rw-r--r-- | ethdb/database.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/ethdb/database.go b/ethdb/database.go index 76e4b4e4d..3dbff36de 100644 --- a/ethdb/database.go +++ b/ethdb/database.go @@ -11,8 +11,8 @@ type LDBDatabase struct { db *leveldb.DB } -func NewLDBDatabase() (*LDBDatabase, error) { - dbPath := path.Join(ethutil.Config.ExecPath, "database") +func NewLDBDatabase(name string) (*LDBDatabase, error) { + dbPath := path.Join(ethutil.Config.ExecPath, name) // Open the db db, err := leveldb.OpenFile(dbPath, nil) @@ -36,6 +36,14 @@ func (db *LDBDatabase) Get(key []byte) ([]byte, error) { return db.db.Get(key, nil) } +func (db *LDBDatabase) Delete(key []byte) error { + return db.db.Delete(key, nil) +} + +func (db *LDBDatabase) Db() *leveldb.DB { + return db.db +} + func (db *LDBDatabase) LastKnownTD() []byte { data, _ := db.db.Get([]byte("LastKnownTotalDifficulty"), nil) @@ -46,13 +54,19 @@ func (db *LDBDatabase) LastKnownTD() []byte { return data } +func (db *LDBDatabase) GetKeys() []*ethutil.Key { + data, _ := db.Get([]byte("KeyRing")) + + return []*ethutil.Key{ethutil.NewKeyFromBytes(data)} +} + func (db *LDBDatabase) Close() { // Close the leveldb database db.db.Close() } func (db *LDBDatabase) Print() { - iter := db.db.NewIterator(nil) + iter := db.db.NewIterator(nil, nil) for iter.Next() { key := iter.Key() value := iter.Value() |