4023661cf1
* added headersOp for safely processing headers * Better handling of protocol messages. * housekeeping + cleanup tests * Added more blockchain logic + unit tests * fixed unreachable error. * added structured logging for all (node) components. * added relay flag + bumped version
25 lines
546 B
Go
25 lines
546 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)
|
|
}
|