046494dd68
* Implemented processing headers + added leveldb as a dependency. * version 0.7.0 * put glide get and install in build_cli section
26 lines
547 B
Go
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)
|
|
}
|