factored out _raft_crop() and _raft_poke()
@@ -1922,33 +1922,16 @@ _raft_grab(u3_noun ova)
int FOO;
-/* u3_raft_work(): work.
+/* _raft_crop(): Delete finished events.
*/
-void
-u3_raft_work(void)
+static void
+_raft_crop(void)
{
- if ( u3Z->typ_e != u3_raty_lead ) {
- c3_assert(u3A->ova.egg_p == 0);
- if ( u3_nul != u3A->roe ) {
- uL(fprintf(uH, "raft: dropping roe!!\n"));
- u3z(u3A->roe);
- u3A->roe = u3_nul;
- }
- }
- else {
- u3_noun ova;
- u3_noun vir;
- u3_noun nex;
-
- // Delete finished events.
- //
while ( u3A->ova.egg_p ) {
u3p(u3v_cart) egg_p = u3A->ova.egg_p;
u3v_cart* egg_u = u3to(u3v_cart, u3A->ova.egg_p);
if ( c3y == egg_u->did ) {
- vir = egg_u->vir;
-
if ( egg_p == u3A->ova.geg_p ) {
c3_assert(egg_u->nex_p == 0);
u3A->ova.geg_p = u3A->ova.egg_p = 0;
@@ -1962,10 +1945,17 @@ u3_raft_work(void)
}
else break;
}
+}
- // Poke pending events, leaving the poked events and errors on u3A->roe.
- //
+
+/* _raft_poke(): Poke pending events, leaving the poked events
+ * and errors on u3A->roe.
+*/
+static void
+_raft_poke(void)
{
+ u3_noun ova, nex;
+
if ( 0 == u3Z->lug_u.len_d ) {
return;
}
@@ -1994,14 +1984,40 @@ u3_raft_work(void)
}
}
+
+/* u3_raft_work(): work.
+*/
+void
+u3_raft_work(void)
+{
+ if ( u3Z->typ_e != u3_raty_lead ) {
+ c3_assert(u3A->ova.egg_p == 0);
+ if ( u3_nul != u3A->roe ) {
+ uL(fprintf(uH, "raft: dropping roe!!\n"));
+ u3z(u3A->roe);
+ u3A->roe = u3_nul;
+ }
+ }
+ else {
+ // Delete finished events.
+ //
+ _raft_crop();
+
+ // Poke pending events, leaving the poked events and errors on u3A->roe.
+ //
+ _raft_poke();
+
// Cartify, jam, and encrypt this batch of events. Take a number, Raft will
// be with you shortly.
{
c3_d bid_d;
c3_w len_w;
c3_w* bob_w;
- u3_noun ron;
+ u3_noun ova;
u3_noun ovo;
+ u3_noun vir;
+ u3_noun nex;
+ u3_noun ron;
ova = u3kb_flop(u3A->roe);
u3A->roe = u3_nul;
