From fe1fa31614a9455a4d482241081a0cd743fd68a0 Mon Sep 17 00:00:00 2001 From: Daniel Petranek Date: Fri, 3 Feb 2023 09:54:27 -0600 Subject: [PATCH] give the history resolver its own cache key prefix If the exact same node key came through the Resolver the CachedHistoryRangeResolver could return the results cached by the CachedTRangeResolver, since they shared the same cache key prefix. This gives it a unique prefix. --- src/fluree/db/index.cljc | 2 +- src/fluree/db/query/range.cljc | 5 +---- test/fluree/db/query/history_test.clj | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fluree/db/index.cljc b/src/fluree/db/index.cljc index 85e09d47e3..6bc41ad404 100644 --- a/src/fluree/db/index.cljc +++ b/src/fluree/db/index.cljc @@ -303,7 +303,7 @@ (if (branch? node) (resolve node-resolver node) (async-cache - [::t-range id tempid tt-id from-t to-t] + [::history-t-range id tempid tt-id from-t to-t] (fn [_] (go-try (let [resolved (> (index/tree-chan resolver idx-root in-range? resolved-leaf? 1 query-xf error-ch) (filter-authorized db start-flake end-flake error-ch) diff --git a/test/fluree/db/query/history_test.clj b/test/fluree/db/query/history_test.clj index 7da722b391..d4195a619b 100644 --- a/test/fluree/db/query/history_test.clj +++ b/test/fluree/db/query/history_test.clj @@ -132,7 +132,9 @@ {:f/t 2 :f/assert [{:ex/x "foo-2" :id :ex/dan}] :f/retract [{:ex/x "foo-1" :id :ex/dan}]} - {:f/t 1 :f/assert [{:ex/x "foo-1" :id :ex/dan}] :f/retract []}] + {:f/t 1 + :f/assert [{:ex/x "foo-1" :id :ex/dan}] + :f/retract []}] @(fluree/history ledger {:history [:ex/dan :ex/x] :t {:to 3}})))) (testing "t-range" (is (= [{:f/t 4