Commit 0fa36c1e authored by liuyuhang's avatar liuyuhang Committed by vipwzw

modify bug

parent 2b2541fd
...@@ -238,14 +238,34 @@ func (mvccs *KVMVCCStore) ProcEvent(msg queue.Message) { ...@@ -238,14 +238,34 @@ func (mvccs *KVMVCCStore) ProcEvent(msg queue.Message) {
// Del set kvs to nil with StateHash // Del set kvs to nil with StateHash
func (mvccs *KVMVCCStore) Del(req *types.StoreDel) ([]byte, error) { func (mvccs *KVMVCCStore) Del(req *types.StoreDel) ([]byte, error) {
kvset, err := mvccs.mvcc.DelMVCC(req.StateHash, req.Height, false) maxVersion, err := mvccs.mvcc.GetMaxVersion()
if err != nil { if err != nil {
kmlog.Error("store kvmvcc del", "err", err) kmlog.Error("store kvmvcc GetMaxVersion failed", "err", err)
return nil, err if err != types.ErrNotFound {
panic(err)
} else {
maxVersion = -1
return nil, err
}
}
var kvset []*types.KeyValue
for i := maxVersion; i >= req.Height; i-- {
hash, err := mvccs.mvcc.GetVersionHash(i)
if err != nil {
kmlog.Debug("store kvmvcc Del GetVersionHash failed", "height", i, "maxVersion", maxVersion)
continue
}
kvlist, err := mvccs.mvcc.DelMVCC(hash, i, false)
if err != nil {
kmlog.Debug("store kvmvcc Del DelMVCC failed", "height", i, "err", err)
continue
}
kvset = append(kvset, kvlist...)
kmlog.Debug("store kvmvcc Del DelMVCC4Height", "height", i, "maxVersion", maxVersion)
}
if len(kvset) > 0 {
mvccs.saveKVSets(kvset, mvccs.sync)
} }
kmlog.Info("KVMVCCStore Del", "hash", common.ToHex(req.StateHash), "height", req.Height)
mvccs.saveKVSets(kvset, mvccs.sync)
return req.StateHash, nil return req.StateHash, nil
} }
......
...@@ -118,4 +118,8 @@ func (chain *BlockChain) sendDelStore(hash []byte, height int64) { ...@@ -118,4 +118,8 @@ func (chain *BlockChain) sendDelStore(hash []byte, height int64) {
if err != nil { if err != nil {
chainlog.Debug("sendDelStoreEvent -->>store", "err", err) chainlog.Debug("sendDelStoreEvent -->>store", "err", err)
} }
_, err = chain.client.Wait(msg)
if err != nil {
panic(fmt.Sprintln("sendDelStore", err))
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment