Small fixes

This commit is contained in:
Oleksandr Brezhniev
2021-06-23 16:59:24 +03:00
parent 1ba9669a29
commit cadeb222c6

View File

@@ -64,7 +64,7 @@ func NewSqlStorage(db *sqlx.DB, errorIfMissing bool) (*Storage, error) {
func (s *Storage) WithPrefix(prefix []byte) merkletree.Storage {
//return &Storage{db: s.db, prefix: merkletree.Concat(s.prefix, prefix)}
// TODO: remove WithPrefix method
mtId := s.mtId<<4 | binary.LittleEndian.Uint64(prefix)
mtId, _ := binary.Uvarint(prefix)
return &Storage{db: s.db, mtId: mtId}
}
@@ -252,6 +252,9 @@ func (tx *StorageTx) Commit() error {
}
}
if tx.currentRoot == nil {
tx.currentRoot = &merkletree.Hash{}
}
_, err := tx.tx.Exec(updateRootStmt, tx.mtId, tx.currentRoot[:])
if err != nil {
return err