diff --git a/src/vault/gear/block-flow.hpp b/src/vault/gear/block-flow.hpp
index 63df043db..e1e361db1 100644
--- a/src/vault/gear/block-flow.hpp
+++ b/src/vault/gear/block-flow.hpp
@@ -300,7 +300,41 @@ namespace gear {
}
else
{//find out how the given time relates to existing Epochs
- UNIMPLEMENTED ("search through existing Epochs to locate the latest one to support given deadline");
+ if (firstEpoch().deadline() >= deadline)
+ // way into the past ... put it in the first available Epoch
+ return AllocatorHandle{alloc_.begin()};
+ else
+ if (lastEpoch().deadline() < deadline)
+ { // a deadline beyond the established Epochs...
+ // create a grid of new epochs up to the requested point
+ TimeVar lastDeadline = lastEpoch().deadline();
+ auto distance = _raw(deadline) - _raw(lastDeadline);
+ EpochIter nextEpoch{alloc_.end()};
+ ENSURE (not nextEpoch); // not valid yet, but we will allocate starting there...
+ auto requiredNew = distance / _raw(epochStep_);
+ if (distance % _raw(epochStep_) > 0)
+ ++requiredNew; // fractional: requested deadline lies within last epoch
+ alloc_.openNew(requiredNew); // Note: epochHandle now points to the first new Epoch
+ for ( ; 0 < requiredNew; --requiredNew)
+ {
+ REQUIRE (nextEpoch);
+ lastDeadline += epochStep_;
+ Epoch::setup (nextEpoch, lastDeadline);
+ if (deadline <= lastDeadline)
+ {
+ ENSURE (requiredNew == 1);
+ return AllocatorHandle{nextEpoch};
+ } // break out and return handle to allocate into the matching Epoch
+ ++nextEpoch;
+ }
+ NOTREACHED ("Logic of counting new Epochs");
+ }
+ else
+ for (EpochIter epochIt{alloc_.begin()}; epochIt; ++epochIt)
+ if (epochIt->deadline() >= deadline)
+ return AllocatorHandle{epochIt};
+
+ NOTREACHED ("Inconsistency in BlockFlow Epoch deadline organisation");
}
}
diff --git a/tests/vault/gear/block-flow-test.cpp b/tests/vault/gear/block-flow-test.cpp
index 480d44d7a..fd7119ba4 100644
--- a/tests/vault/gear/block-flow-test.cpp
+++ b/tests/vault/gear/block-flow-test.cpp
@@ -221,17 +221,17 @@ namespace test {
CHECK (watch(bFlow).find(a1) == "10s200ms"_expect);
auto& a3 = bFlow.until(t3).create();
- CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s0ms"_expect);
- CHECK (watch(bFlow).find(a3) == "11s0ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s"_expect);
+ CHECK (watch(bFlow).find(a3) == "11s"_expect);
auto& a2 = bFlow.until(t2).create();
- CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s00ms"_expect);
- CHECK (watch(bFlow).find(a2) == "11s600ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s"_expect);
+ CHECK (watch(bFlow).find(a2) == "10s600ms"_expect);
Time t0 = Time{0,5};
auto& a0 = bFlow.until(t0).create();
- CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s00ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s"_expect);
CHECK (watch(bFlow).find(a0) == "10s200ms"_expect);
BlockFlow::AllocatorHandle allocHandle = bFlow.until(Time{300,10});
@@ -261,14 +261,14 @@ namespace test {
CHECK (not allocHandle.hasFreeSlot());
auto& a6 = bFlow.until(Time{850,10}).create();
CHECK (watch(bFlow).find(a6) == "11s150ms"_expect);
- CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s00ms|11s150ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11sms|11s150ms"_expect);
auto& a7 = bFlow.until(Time{500,11}).create();
CHECK (watch(bFlow).find(a7) == "11s600ms"_expect);
- CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11s00ms|11s150ms|11s300ms|11s450ms|11s600ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "10s200ms|10s400ms|10s600ms|10s800ms|11sms|11s150ms|11s300ms|11s450ms|11s600ms"_expect);
bFlow.discardBefore (Time{999,10});
- CHECK (watch(bFlow).allEpochs() == "11s00ms|11s150ms|11s300ms|11s450ms|11s600ms"_expect);
+ CHECK (watch(bFlow).allEpochs() == "11s|11s150ms|11s300ms|11s450ms|11s600ms"_expect);
auto& a8 = bFlow.until(Time{500,10}).create();
CHECK (watch(bFlow).find(a8) == "11s150ms"_expect);
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm
index 087fdf70b..86871e7b2 100644
--- a/wiki/thinkPad.ichthyo.mm
+++ b/wiki/thinkPad.ichthyo.mm
@@ -78887,20 +78887,20 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
@@ -79995,8 +79995,8 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
@@ -80005,16 +80005,15 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
-
-
+
+
+
-
-
+
+
-
-
+
+
@@ -80060,22 +80059,24 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
+
-
-
+
+
-
+
+
-
-
+
+
+
@@ -80278,8 +80279,8 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
+
+
@@ -80295,15 +80296,6 @@ Date: Thu Apr 20 18:53:17 2023 +0200
-
-
-
-
-
-
-
-
-
@@ -80338,6 +80330,15 @@ Date: Thu Apr 20 18:53:17 2023 +0200
+
+
+
+
+
+
+
+
+