Browse Source

fix evidence db iter leak (#2516)

Also make reversing a slice more efficient
pull/2531/head
goolAdapter 6 years ago
committed by Anton Kaliaev
parent
commit
5c6999cf8f
2 changed files with 6 additions and 4 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +5
    -4
      evidence/store.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -39,3 +39,4 @@ IMPROVEMENTS:
BUG FIXES:
- [autofile] \#2428 Group.RotateFile need call Flush() before rename (@goolAdapter)
- [node] \#2434 Make node respond to signal interrupts while sleeping for genesis time
- [evidence] \#2515 fix db iter leak (@goolAdapter)

+ 5
- 4
evidence/store.go View File

@ -79,11 +79,11 @@ func NewEvidenceStore(db dbm.DB) *EvidenceStore {
func (store *EvidenceStore) PriorityEvidence() (evidence []types.Evidence) {
// reverse the order so highest priority is first
l := store.listEvidence(baseKeyOutqueue, -1)
l2 := make([]types.Evidence, len(l))
for i := range l {
l2[i] = l[len(l)-1-i]
for i, j := 0, len(l)-1; i < j; i, j = i+1, j-1 {
l[i], l[j] = l[j], l[i]
}
return l2
return l
}
// PendingEvidence returns known uncommitted evidence up to maxBytes.
@ -98,6 +98,7 @@ func (store *EvidenceStore) PendingEvidence(maxBytes int64) (evidence []types.Ev
func (store *EvidenceStore) listEvidence(prefixKey string, maxBytes int64) (evidence []types.Evidence) {
var bytes int64
iter := dbm.IteratePrefix(store.db, []byte(prefixKey))
defer iter.Close()
for ; iter.Valid(); iter.Next() {
val := iter.Value()


Loading…
Cancel
Save