func (iter *dbCacheIterator) Last() bool {
	iter.dbIter.Last()
	iter.cacheIter.Last()
	return iter.chooseIterator(false)
}
Last positions the iterator at the last key/value pair and returns whether or
not the pair exists.

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)
}