Skip to content

Commit

Permalink
Merge tag '0.9.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
earlbread committed May 20, 2020
2 parents 135fb95 + 2bb11fb commit 4d7cc98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ To be released.
[#868]: https://github.com/planetarium/libplanet/pull/868


Version 0.9.2
-------------

Released on May 20, 2020.

- (Libplanet.RocksDBStore) Fixed a memory leak bug in `RocksDBStore`. [[#870]]

[#870]: https://github.com/planetarium/libplanet/pull/870


Version 0.9.1
-------------

Expand Down
14 changes: 7 additions & 7 deletions Libplanet.RocksDBStore/RocksDBStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,8 @@ public override IEnumerable<Tuple<HashDigest<SHA256>, long>> IterateStateReferen
byte[] keyBytes = RocksDBStoreBitConverter.GetBytes(key);
byte[] prefix = StateRefKeyPrefix.Concat(keyBytes).ToArray();

ColumnFamilyHandle cf = GetColumnFamily(_stateRefDb, chainId);
Iterator it = _stateRefDb.NewIterator(cf);

return IterateStateReferences(
prefix, it, highestIndex.Value, lowestIndex.Value, limit.Value);
chainId, prefix, highestIndex.Value, lowestIndex.Value, limit.Value);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -773,7 +770,7 @@ public override void ForkStateReferences<T>(
_stateRefDb.Put(key, it.Value(), destCf);
}

Iterator destIt = _stateRefDb.NewIterator(destCf);
using Iterator destIt = _stateRefDb.NewIterator(destCf);

destIt.Seek(prefix);

Expand Down Expand Up @@ -883,12 +880,15 @@ private void DeleteBlockStates(
}

private IEnumerable<Tuple<HashDigest<SHA256>, long>> IterateStateReferences(
Guid chainId,
byte[] prefix,
Iterator it,
long highestIndex,
long lowestIndex,
int limit)
{
ColumnFamilyHandle cf = GetColumnFamily(_stateRefDb, chainId);
using Iterator it = _stateRefDb.NewIterator(cf);

// FIXME: We need to change the state reference to be ordered by reverse byte-wise
// and use the Seek function.
it.SeekToLast();
Expand Down Expand Up @@ -961,7 +961,7 @@ private byte[] StateRefKey(string stateKey, long blockIndex)
private IEnumerable<Iterator> IterateDb(RocksDb db, byte[] prefix, Guid? chainId = null)
{
ColumnFamilyHandle cf = GetColumnFamily(db, chainId);
Iterator it = db.NewIterator(cf);
using Iterator it = db.NewIterator(cf);
for (it.Seek(prefix); it.Valid() && it.Key().StartsWith(prefix); it.Next())
{
yield return it;
Expand Down

0 comments on commit 4d7cc98

Please sign in to comment.