Skip to content

Commit 1414868

Browse files
committed
fix: remove proposal and ballot from pool in LoadDatabase
1 parent 48aef10 commit 1414868

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

isaac/database/pool.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ func (db *TempPool) startClean(ctx context.Context) error {
864864
ticker := time.NewTicker(db.cleanRemovedNewOperationsInterval)
865865
defer ticker.Stop()
866866

867+
_, _ = db.cleanProposals()
868+
_, _ = db.cleanBallots()
869+
867870
for {
868871
select {
869872
case <-ctx.Done():
@@ -977,6 +980,20 @@ func (db *TempPool) cleanBallots() (int, error) {
977980
return db.cleanByHeight(leveldbKeyPrefixBallot, db.cleanRemovedBallotDeep, nil)
978981
}
979982

983+
func (db *TempPool) CleanProposalsAndBallots() (int, error) {
984+
_, err := db.cleanByHeight(
985+
leveldbKeyPrefixProposalByPoint,
986+
0,
987+
func(batch *leveldbstorage.PrefixStorageBatch, _ []byte, b []byte) {
988+
batch.Delete(leveldbProposalKey(valuehash.Bytes(b)))
989+
},
990+
)
991+
if err != nil {
992+
return 0, err
993+
}
994+
return db.cleanByHeight(leveldbKeyPrefixBallot, 0, nil)
995+
}
996+
980997
func (db *TempPool) cleanByHeight(
981998
prefix leveldbstorage.KeyPrefix,
982999
deep int,

launch/p_storage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ func LoadDatabase(
826826
return nil, nil, nil, nil, e.Wrap(err)
827827
}
828828

829+
_, err = pool.CleanProposalsAndBallots()
830+
if err != nil {
831+
return nil, nil, nil, nil, e.Wrap(err)
832+
}
833+
829834
return st, db, perm, pool, nil
830835
}
831836

0 commit comments

Comments
 (0)