提交 2b6925af 编写于 作者: D dp524856

add rebuild

上级 28f93e9d
......@@ -7,6 +7,7 @@ import (
"io/ioutil"
"math"
"math/bits"
// "unsafe"
// "github.com/ethereum/go-ethereum/common"
......@@ -131,18 +132,6 @@ func ParseConfig(fileName string) (*Options, error) {
// SaveConfig saves config to file.
func SaveConfig(config *Options, fileName string) error {
//file, err := os.Create(fileName)
//if err != nil {
// return err
//}
//
//defer file.Close()
//data, err := json.MarshalIndent(config, " ", "")
//n, err := file.Write(data)
//if n != len(data) || err != nil {
// return err
//}
//file.Sync()
return nil
}
......
......@@ -2,6 +2,7 @@ package storage
import (
"fmt"
"github.com/yottachain/YTFS/common"
"github.com/yottachain/YTFS/opt"
)
......@@ -37,6 +38,21 @@ func (ti *TableIterator) GetTable() (common.IndexTable, error) {
return table, nil
}
func (ti *TableIterator) GetNoNilTable() (common.IndexTable, error) {
for {
table, err := ti.GetTable()
if err != nil {
return nil, err
}
if table == nil {
panic(fmt.Errorf("index.db文件已损坏,无法恢复"))
}
if len(table) > 0 {
return table, nil
}
}
}
func (ti *TableIterator) Reset() {
ti.tableIndex = 0
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册