neoneo-go/pkg/core/leveldb_store.go
Anthony De Meulemeester 046494dd68
Implemented processing headers + added leveldb as a dependency. (#16)
* Implemented processing headers + added leveldb as a dependency.

* version 0.7.0

* put glide get and install in build_cli section
2018-02-06 07:43:32 +01:00

26 lines
547 B
Go

package core
import (
"github.com/syndtr/goleveldb/leveldb"
)
// LevelDBStore is the official storage implementation for storing and retreiving
// the blockchain.
type LevelDBStore struct {
db *leveldb.DB
}
// Write implements the Store interface.
func (s *LevelDBStore) write(key, value []byte) error {
return s.db.Put(key, value, nil)
}
// WriteBatch implements the Store interface.
func (s *LevelDBStore) writeBatch(batch Batch) error {
b := new(leveldb.Batch)
for k, v := range batch {
b.Put(*k, v)
}
return s.db.Write(b, nil)
}