func (itr *RangeScanIterator) Next() bool {
	if itr.done {
		return false
	}
	for ; itr.dbItr.Valid(); itr.dbItr.Next() {
		trieKeyBytes := statemgmt.Copy(itr.dbItr.Key().Data())
		trieNodeBytes := statemgmt.Copy(itr.dbItr.Value().Data())
		value := unmarshalTrieNodeValue(trieNodeBytes)
		if util.IsNil(value) {
			continue
		}
		currentCompositeKey := trieKeyEncoderImpl.decodeTrieKeyBytes(statemgmt.Copy(trieKeyBytes))
		currentChaincodeID, currentKey := statemgmt.DecodeCompositeKey(currentCompositeKey)
		if currentChaincodeID == itr.chaincodeID && (itr.endKey == "" || currentKey <= itr.endKey) {
			itr.currentKey = currentKey
			itr.currentValue = value
			itr.dbItr.Next()
			return true
		}
		break
	}
	itr.done = true
	return false
}
Next - see interface 'statemgmt.RangeScanIterator' for details
package trie
import (
	"github.com/openblockchain/obc-peer/openchain/db"
	"github.com/openblockchain/obc-peer/openchain/ledger/statemgmt"
	"github.com/openblockchain/obc-peer/openchain/ledger/util"
	"github.com/tecbot/gorocksdb"
)
type RangeScanIterator struct {
	dbItr        *gorocksdb.Iterator
	chaincodeID  string
	endKey       string
	currentKey   string
	currentValue []byte
	done         bool
}
func newRangeScanIterator(chaincodeID string, startKey string, endKey string) (*RangeScanIterator, error) {
	dbItr := db.GetDBHandle().GetStateCFIterator()
	encodedStartKey := newTrieKey(chaincodeID, startKey).getEncodedBytes()
	dbItr.Seek(encodedStartKey)
	return &RangeScanIterator{dbItr, chaincodeID, endKey, "", nil, false}, nil
}