private ConsumerSession[] Filter(
            Keccak?depositId         = null,
            Keccak?dataAssetId       = null,
            PublicKey?consumerNodeId = null,
            Address?consumerAddress  = null,
            PublicKey?providerNodeId = null,
            Address?providerAddress  = null)
        {
            byte[][] sessionsBytes = _database.GetAllValues().ToArray();
            if (sessionsBytes.Length == 0)
            {
                return(Array.Empty <ConsumerSession>());
            }

            ConsumerSession[] sessions = new ConsumerSession[sessionsBytes.Length];
            for (int i = 0; i < sessionsBytes.Length; i++)
            {
                sessions[i] = Decode(sessionsBytes[i]);
            }

            if (depositId is null && dataAssetId is null && consumerNodeId is null && consumerAddress is null &&
                providerNodeId is null && providerAddress is null)
            {
                return(sessions);
            }

            IEnumerable <ConsumerSession> filteredSessions = sessions.AsEnumerable();

            if (!(depositId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.DepositId == depositId);
            }

            if (!(dataAssetId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.DataAssetId == dataAssetId);
            }

            if (!(consumerNodeId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ConsumerNodeId == consumerNodeId);
            }

            if (!(consumerAddress is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ConsumerAddress == consumerAddress);
            }

            if (!(providerNodeId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ProviderNodeId == providerNodeId);
            }

            if (!(providerAddress is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ProviderAddress == providerAddress);
            }

            return(filteredSessions.OrderByDescending(s => s.StartTimestamp).ToArray());
        }
        private IReadOnlyList <ConsumerSession> Filter(Keccak depositId         = null, Keccak dataAssetId = null,
                                                       PublicKey consumerNodeId = null, Address consumerAddress = null, PublicKey providerNodeId = null,
                                                       Address providerAddress  = null)
        {
            var sessionsBytes = _database.GetAll();

            if (sessionsBytes.Length == 0)
            {
                return(Array.Empty <ConsumerSession>());
            }

            var sessions = new ConsumerSession[sessionsBytes.Length];

            for (var i = 0; i < sessionsBytes.Length; i++)
            {
                sessions[i] = Decode(sessionsBytes[i]);
            }

            if (depositId is null && dataAssetId is null && consumerNodeId is null && consumerAddress is null &&
                providerNodeId is null && providerAddress is null)
            {
                return(sessions);
            }

            var filteredSessions = sessions.AsEnumerable();

            if (!(depositId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.DepositId == depositId);
            }

            if (!(dataAssetId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.DataAssetId == dataAssetId);
            }

            if (!(consumerNodeId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ConsumerNodeId == consumerNodeId);
            }

            if (!(consumerAddress is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ConsumerAddress == consumerAddress);
            }

            if (!(providerNodeId is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ProviderNodeId == providerNodeId);
            }

            if (!(providerAddress is null))
            {
                filteredSessions = filteredSessions.Where(s => s.ProviderAddress == providerAddress);
            }

            return(filteredSessions.OrderByDescending(s => s.StartTimestamp).ToArray());
        }