func (iter *dbCacheIterator) Key() []byte {
	if iter.currentIter == nil {
		return nil
	}
	return iter.currentIter.Key()
}
Key returns the current key the iterator is pointing to.

This is part of the leveldb iterator.Iterator interface implementation.
package ffldb
import (
	"bytes"
	"fmt"
	"sync"
	"time"
	"github.com/soteria-dag/soterd/database/internal/treap"
	"github.com/btcsuite/goleveldb/leveldb"
	"github.com/btcsuite/goleveldb/leveldb/iterator"
	"github.com/btcsuite/goleveldb/leveldb/util"
)
const (
	defaultCacheSize = 100 * 1024 * 1024  
	defaultFlushSecs = 300  
	ldbBatchHeaderSize = 12
	ldbRecordIKeySize  = 8
)
type ldbCacheIter struct {
	*treap.Iterator
}
var _ iterator.Iterator = (*ldbCacheIter)(nil)
func (iter *ldbCacheIter) Error() error {
	return nil
}
func (iter *ldbCacheIter) SetReleaser(releaser util.Releaser) {
}
func (iter *ldbCacheIter) Release() {
}
func newLdbCacheIter(snap *dbCacheSnapshot, slice *util.Range) *ldbCacheIter {
	iter := snap.pendingKeys.Iterator(slice.Start, slice.Limit)
	return &ldbCacheIter{Iterator: iter}
}
type dbCacheIterator struct {
	cacheSnapshot *dbCacheSnapshot
	dbIter        iterator.Iterator
	cacheIter     iterator.Iterator
	currentIter   iterator.Iterator
	released      bool
}
var _ iterator.Iterator = (*dbCacheIterator)(nil)
func (iter *dbCacheIterator) skipPendingUpdates(forwards bool) {
	for iter.dbIter.Valid() {
		var skip bool
		key := iter.dbIter.Key()
		if iter.cacheSnapshot.pendingRemove.Has(key) {
			skip = true
		} else if iter.cacheSnapshot.pendingKeys.Has(key) {
			skip = true
		}
		if !skip {
			break
		}
		if forwards {
			iter.dbIter.Next()
		} else {
			iter.dbIter.Prev()
		}
	}
}
func (iter *dbCacheIterator) chooseIterator(forwards bool) bool {
	iter.skipPendingUpdates(forwards)
	if !iter.dbIter.Valid() && !iter.cacheIter.Valid() {
		iter.currentIter = nil
		return false
	}
	if !iter.cacheIter.Valid() {
		iter.currentIter = iter.dbIter
		return true
	}
	if !iter.dbIter.Valid() {
		iter.currentIter = iter.cacheIter
		return true
	}
	compare := bytes.Compare(iter.dbIter.Key(), iter.cacheIter.Key())
	if (forwards && compare > 0) || (!forwards && compare < 0) {
		iter.currentIter = iter.cacheIter
	} else {
		iter.currentIter = iter.dbIter
	}
	return true
}
func (iter *dbCacheIterator) First() bool {
	iter.dbIter.First()
	iter.cacheIter.First()
	return iter.chooseIterator(true)
}
func (iter *dbCacheIterator) Last() bool {
	iter.dbIter.Last()
	iter.cacheIter.Last()
	return iter.chooseIterator(false)
}
func (iter *dbCacheIterator) Next() bool {
	if iter.currentIter == nil {
		return false
	}
	iter.currentIter.Next()
	return iter.chooseIterator(true)
}
func (iter *dbCacheIterator) Prev() bool {
	if iter.currentIter == nil {
		return false
	}
	iter.currentIter.Prev()
	return iter.chooseIterator(false)
}
func (iter *dbCacheIterator) Seek(key []byte) bool {
	iter.dbIter.Seek(key)
	iter.cacheIter.Seek(key)
	return iter.chooseIterator(true)
}
func (iter *dbCacheIterator) Valid() bool {
	return iter.currentIter != nil
}