diff --git a/interface/store/arbiters.go b/interface/store/arbiters.go index de6bfe8..41fe0ed 100644 --- a/interface/store/arbiters.go +++ b/interface/store/arbiters.go @@ -180,11 +180,22 @@ func (c *arbiters) Clear() error { c.Lock() defer c.Unlock() it := c.db.NewIterator(dbutil.BytesPrefix(BKTArbiters), nil) - defer it.Release() for it.Next() { c.b.Delete(it.Key()) } + it.Release() c.b.Delete(BKTArbPosition) + c.b.Delete(BKTArbPositions) + it = c.db.NewIterator(dbutil.BytesPrefix(BKTArbitersData), nil) + for it.Next() { + c.b.Delete(it.Key()) + } + it.Release() + it = c.db.NewIterator(dbutil.BytesPrefix(BKTTransactionHeight), nil) + for it.Next() { + c.b.Delete(it.Key()) + } + it.Release() return c.db.Write(c.b, nil) } diff --git a/interface/store/customid.go b/interface/store/customid.go index 1edd824..2ff8e37 100644 --- a/interface/store/customid.go +++ b/interface/store/customid.go @@ -556,22 +556,29 @@ func (c *customID) Clear() error { batch := new(leveldb.Batch) it := c.db.NewIterator(util.BytesPrefix(BKTReservedCustomID), nil) - defer it.Release() for it.Next() { batch.Delete(it.Key()) } + it.Release() it = c.db.NewIterator(util.BytesPrefix(BKTReceivedCustomID), nil) - defer it.Release() for it.Next() { batch.Delete(it.Key()) } + it.Release() it = c.db.NewIterator(util.BytesPrefix(BKTChangeCustomIDFee), nil) - defer it.Release() for it.Next() { batch.Delete(it.Key()) } + it.Release() + + it = c.db.NewIterator(util.BytesPrefix(BKTLastCustomIDFee), nil) + for it.Next() { + batch.Delete(it.Key()) + } + it.Release() + return c.db.Write(c.b, nil) } diff --git a/interface/store/upgrade.go b/interface/store/upgrade.go index 156e8ca..9052e84 100644 --- a/interface/store/upgrade.go +++ b/interface/store/upgrade.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "github.com/elastos/Elastos.ELA/core/types/payload" + dbutil "github.com/syndtr/goleveldb/leveldb/util" "sync" "github.com/elastos/Elastos.ELA/common" @@ -11,7 +12,7 @@ import ( "github.com/syndtr/goleveldb/leveldb" ) -// Ensure arbiters implement arbiters interface. +// Ensure upgrade implement Upgrade interface. var _ Upgrade = (*upgrade)(nil) type upgrade struct { @@ -23,7 +24,22 @@ type upgrade struct { } func (u *upgrade) Clear() error { - panic("implement me") + u.Lock() + defer u.Unlock() + it := u.db.NewIterator(dbutil.BytesPrefix(BKTUpgradeControversial), nil) + for it.Next() { + u.b.Delete(it.Key()) + } + it.Release() + it = u.db.NewIterator(dbutil.BytesPrefix(BKTUpgradeCode), nil) + for it.Next() { + u.b.Delete(it.Key()) + } + it.Release() + + u.b.Delete(BKTUpgradePositions) + + return u.db.Write(u.b, nil) } func (u *upgrade) Close() error { @@ -80,7 +96,7 @@ func (u *upgrade) batchPutUpgradeResult(proposalHash common.Uint256, batch *leve } newPosCache = append(newPosCache, info.WorkingHeight) u.posCache = newPosCache - batch.Put(BKTArbPositions, uint32ArrayToBytes(u.posCache)) + batch.Put(BKTUpgradePositions, uint32ArrayToBytes(u.posCache)) index := getIndex(info.WorkingHeight) batch.Put(toKey(BKTUpgradeCode, index...), data)