From: rtrimana Date: Fri, 5 Aug 2016 00:01:58 +0000 (-0700) Subject: More clean-ups on functions X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c1502aa06f74c85adb74ddac2e9b931dd9dd955f;p=iotcloud.git More clean-ups on functions --- diff --git a/doc/iotcloud.tex b/doc/iotcloud.tex index ff6f3d8..e389472 100644 --- a/doc/iotcloud.tex +++ b/doc/iotcloud.tex @@ -147,8 +147,8 @@ $MaxSlot(SL_s)= \tuple{s, sv} \mid \tuple{s, sv} \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \geq s_s$ \\ $MinSlot(SL_s)= \tuple{s, sv} \mid \tuple{s, sv} \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \leq s_s$ \\ -$SeqN(\tuple{s, sv})=s$ \\ -$SlotVal(\tuple{s, sv})=sv$ \\ +$SeqN(slot_s = \tuple{s, sv})=s$ \\ +$SlotVal(slot_s = \tuple{s, sv})=sv$ \\ \begin{algorithmic}[1] \Function{GetSlot}{$s_g$} @@ -162,7 +162,7 @@ $SlotVal(\tuple{s, sv})=sv$ \\ \State $max \gets max'$ \EndIf \State $\tuple{s_n,sv_n} \gets MaxSlot(SL)$\Comment{Last sv} -\State $s_n \gets SeqN(\tuple{s_n,sv_n})$ +%\State $s_n \gets SeqN(\tuple{s_n,sv_n})$ \If{$(s_p = s_n + 1)$} \If{$n = max$} \State $\tuple{s_m,sv_m} \gets MinSlot(SL)$\Comment{First sv} @@ -227,6 +227,7 @@ $Slot(SL_s,s_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv} $SeqN(\tuple{s, sv})=s$ \\ $SlotVal(\tuple{s, sv})=sv$ \\ $CreateLastSL(s,sv,id)=\tuple{s,sv,id}=sl_{last}$ \\ +$CreateEntLV(kv_s,s_s)=\tuple{kv_s,s_s}$ \\ $Decrypt(SK_s,sv_s)=Dat_s=\tuple{s,id,hmac_p,DE,hmac_c}$ \\ $GetSeqN(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=s$ \\ $GetMacId(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=id$ \\ @@ -237,16 +238,18 @@ $GetLiveSS(SS_{live},ss_s)= ss$ \textit{such that} $ss \in SS_{live} \wedge \forall ss_s \in SS_{live}, ss = ss_s$ \\ $GetLiveCR(CR_{live},cr_s)= cr$ \textit{such that} $cr \in CR_{live} \wedge \forall cr_s \in CR_{live}, cr = cr_s$ \\ -$GetLivEntLastS(LV_s,de_s)= s$ \textit{such that} $\tuple{de, s} \in LV_s -\wedge \forall \tuple{de_s, s_s} \in LV_s, de_s = de$ \\ +$GetLivEntLastS(LV_s,kv_s)= s$ \textit{such that} $\tuple{kv, s} \in LV_s +\wedge \forall \tuple{kv_s, s_s} \in LV_s, kv_s = kv$ \\ $GetKV($key-value data entry$)=\tuple{k_s,v_s} = kv_s$ \\ $GetSS($slot-sequence data entry$)=\tuple{id_s,s_{s_{last}}} = ss_s$ \\ $GetQS($queue-state data entry$)=qs_s$ \\ $GetCR($collision-resolution data entry$)=\tuple{s_s,id_s} = cr_s$ \\ -$GetS(\tuple{s, id})=s$ \\ -$GetId(\tuple{s, id})=id$ \\ -$GetKey(\tuple{k, v})=k$ \\ -$GetVal(\tuple{k, v})=v$ \\ +$GetKey(kv = \tuple{k, v})=k$ \\ +$GetVal(kv = \tuple{k, v})=v$ \\ +$GetId(ss = \tuple{id, s_{last}})=id$ \\ +$GetSLast(ss = \tuple{id, s_{last}})=s_{last}$ \\ +$GetS(cr = \tuple{s, id})=s$ \\ +$GetId(cr = \tuple{s, id})=id$ \\ $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \in DT_s \wedge \forall \tuple{k_s, v_s} \in DT_s, k = k_s$ \\ $MaxLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s @@ -293,14 +296,14 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \begin{algorithmic}[1] \Function{GetSlotSeq}{$DE_s$} -\State $DE_{ss} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = ss\}$ +\State $DE_{ss} \gets \{de_s | de_s \in DE_s, de_s = ss\}$ \State \Return{$DE_{ss}$} \EndFunction \end{algorithmic} \begin{algorithmic}[1] \Function{GetColRes}{$DE_s$} -\State $DE_{cr} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = cr\}$ +\State $DE_{cr} \gets \{de_s | de_s \in DE_s, de_s = cr\}$ \State \Return{$DE_{cr}$} \EndFunction \end{algorithmic} @@ -318,14 +321,14 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Function{UpdateKVLivEnt}{$LV_s,de_s,s_s$} -\State $s_t \gets GetLivEntLastS(LV_s,de_s)$ +\Function{UpdateKVLivEnt}{$LV_s,kv_s,s_s$} +\State $s_t \gets GetLivEntLastS(LV_s,kv_s)$ \If{$s_t = \emptyset$} - \State $LV_s \gets LV_s \cup \{\tuple{de_s,s_s}\}$\Comment{First occurrence} + \State $LV_s \gets LV_s \cup \{\tuple{kv_s,s_s}\}$\Comment{First occurrence} \Else \If{$s_s > s_t$}\Comment{Update entry with a later s} - \State $LV_s \gets (LV_s - \{\tuple{de_s,s_t}\}) \cup - \{\tuple{de_s,s_s}\}$ + \State $LV_s \gets (LV_s - \{\tuple{kv_s,s_t}\}) \cup + \{\tuple{kv_s,s_s}\}$ \EndIf \EndIf \State \Return{$LV_s$} @@ -358,9 +361,9 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \Function{UpdateSSLivEnt}{$SS_{s_{live}},MS_s$} \State $s_{s_{min}} \gets MinLastSeqN(MS_s)$ \ForAll{$ss_s \in SS_{s_{live}}$} - \State $\tuple{id_s,s_{s_{last}}} \gets GetSS(ss_s)$ + \State $s_{s_{last}} \gets GetSLast(ss_s)$ \If{$s_{s_{min}} > s_{s_{last}}$}\Comment{Remove if dead} - \State $SS_{s_{live}} \gets SS_{s_{live}} - \{\tuple{id_s,s_{s_{last}}}\}$ + \State $SS_{s_{live}} \gets SS_{s_{live}} - \{ss_s\}$ \EndIf \EndFor \State \Return{$SS_{s_{live}}$} @@ -371,9 +374,9 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \Function{UpdateCRLivEnt}{$CR_{s_{live}},MS_s$} \State $s_{s_{min}} \gets MinLastSeqN(MS_s)$ \ForAll{$cr_s \in CR_{s_{live}}$} - \State $\tuple{s_s,id_s} \gets GetCR(cr_s)$ + \State $s_s \gets GetS(cr_s)$ \If{$s_{s_{min}} > s_s$}\Comment{Remove if dead} - \State $SS_{s_{live}} \gets SS_{s_{live}} - \{\tuple{s_s,id_s}\}$ + \State $CR_{s_{live}} \gets CR_{s_{live}} - \{cr_s\}$ \EndIf \EndFor \State \Return{$CR_{s_{live}}$} @@ -381,8 +384,8 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Procedure{CheckLastSeqN}{$MS_s,MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$} -\For {$\tuple{id, s_t}$ in $MS_t$} +\Procedure{CheckLastSeqN}{$MS_s,MS_t$} +\For {$\tuple{id, s_t}$ in $MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$} \State $s_s \gets MS_s[id]$ \If{$s_s = \emptyset$} \Call{Error}{'No $s$ for machine $id$'} @@ -398,23 +401,24 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Procedure{CheckCollision}{$MS_s,SM_s,\tuple{s_s,id_s}$} -\If{$\tuple{s_s,id_s} \neq \emptyset$} - \State $s_s \gets GetS(\tuple{s_s,id_s})$ - \State $id_s \gets GetId(\tuple{s_s,id_s})$ +\Procedure{CheckCollision}{$MS_s,SM_s,cr_s$} +\If{$cr_s \neq \emptyset$} + \State $s_s \gets GetS(cr_s)$ + \State $id_s \gets GetId(cr_s)$ \State $s_{s_{last}} \gets GetLastSeqN(MS_s,id_s)$ \If{$s_{s_{last}} < s_s$} - \State $\Call{CheckColRes}{SM_s,\tuple{s_s,id_s}}$ + \State $\Call{CheckColRes}{SM_s,cr_s}$ \EndIf \EndIf \EndProcedure \end{algorithmic} \begin{algorithmic}[1] -\Procedure{CheckColRes}{$SM_s,\tuple{s_t,id_t}$}\Comment{Check $id_s$ in $SM_s$} +\Procedure{CheckColRes}{$SM_s,cr_t$}\Comment{Check $id_s$ in $SM_s$} +\State $s_t \gets GetS(cr_t)$ \State $id_s \gets SM_s[s_t]$ \If{$id_s \neq id_t$} - \State \Call{Error}{'Invalid $id_s$ for this slot update'} + \State \Call{Error}{'Invalid $id$ for this slot update'} \EndIf \EndProcedure \end{algorithmic} @@ -431,18 +435,18 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \begin{algorithmic}[1] \Function{UpdateDT}{$DT_s,DE_s,LV_s,s_s$} +\State $DE_{s_{kv}} \gets \{de_s | de_s \in DE_s, de_s = kv\}$ \ForAll{$de_s \in DE_s$} - \State $LV_s \gets \Call{UpdateKVLivEnt}{LV_s,de_s,s_s}$ - \If{$de_s$ \textit{such that} $de_s \in D \land de_s = kv$} - \State $\tuple{k_s,v_s} \gets GetKV(de_s)$ - \State $\tuple{k_s,v_t} \gets GetKeyVal(DT_s,k_s)$ - \If{$\tuple{k_s,v_t} = \emptyset$} - \State $DT_s \gets DT_s \cup \{\tuple{k_s,v_s}\}$ - \Else - \State $DT_s \gets (DT_s - \{\tuple{k_s,v_t}\}) \cup + \State $kv_s \gets GetKV(de_s)$ + \State $LV_s \gets \Call{UpdateKVLivEnt}{LV_s,kv_s,s_s}$ + \State $k_s \gets GetKey(kv_s)$ + \State $\tuple{k_s,v_t} \gets GetKeyVal(DT_s,k_s)$ + \If{$\tuple{k_s,v_t} = \emptyset$} + \State $DT_s \gets DT_s \cup \{\tuple{k_s,v_s}\}$ + \Else + \State $DT_s \gets (DT_s - \{\tuple{k_s,v_t}\}) \cup \{\tuple{k_s,v_s}\}$ - \EndIf - \EndIf + \EndIf \EndFor \State \Return{$DT_s$} \EndFunction @@ -452,8 +456,8 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \Procedure{ProcessSL}{$SL_g$} \State $MS_g \gets \emptyset$ \State $SM_{curr} \gets \emptyset$ -\State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$ \State $\tuple{s_{g_{min}},sv_{g_{min}}} \gets MinSlot(SL_g)$ +\State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$ \For{$s_g \gets s_{g_{min}}$ \textbf{to} $s_{g_{max}}$}\Comment{Process slots in $SL_g$ in order} \State $\tuple{s_g,sv_g} \gets Slot(SL_g,s_g)$ @@ -492,9 +496,9 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \State $DE_{g_{cr}} \gets \Call{GetColRes}{DE_g}$\Comment{Handle cr} \If{$DE_{g_{cr}} \neq \emptyset$} \ForAll{$de_{g_{cr}} \in DE_{g_{cr}}$} - \State $\tuple{s_e,id_e} \gets GetCR(de_{g_{cr}})$ - \State $\Call{CheckCollision}{MS,SM,\tuple{s_e,id_e}}$ - \State $CR_{live} \gets \Call{AddCRLivEnt}{SS_{live},de_{g_{cr}}}$ + \State $cr_g \gets GetCR(de_{g_{cr}})$ + \State $\Call{CheckCollision}{MS,SM,cr_g}$ + \State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},de_{g_{cr}}}$ \EndFor \EndIf \State $sl_{last} \gets \Call{StoreLastSlot}{MS,sl_{last},s_g,sv_g,id_g}$ @@ -504,7 +508,7 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \If{$m + |SL_g| \leq max_g$}\Comment{Check actual size against $max_g$} \State $m \gets m + |SL_g|$ \Else - \State \Call{Error}{'Actual queue size exceeds $max_g$'} + \State \Call{Error}{'Actual $SL$ size on server exceeds $max_g$'} \EndIf \State $\Call{CheckLastSeqN}{MS_g,MS}$ \State $\Call{UpdateSSLivEnt}{SS_{live},MS}$ @@ -529,21 +533,12 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \subsubsection{Writing Slots} -\textbf{Data Entry} \\ -$k$ is key of entry \\ -$v$ is value of entry \\ -$kv$ is a key-value entry $\tuple{k,v}$\\ -$D = \{kv,ss,qs,cr\}$ \\ -$DE = \{de \mid de \in D\}$ \\ -$Dat_s = \tuple{s,id,hmac_p,DE,hmac_c}$ \\ -$sv_s = \tuple{s, E(Dat_s)} = -\tuple{s, E(\tuple{s,id,hmac_p,DE,hmac_c})}$ \\ \\ \textbf{States} \\ \textit{$cp$ = data entry $DE$ maximum size/capacity} \\ -\textit{$cr_p$ = saved cr entry $\tuple{s,id}$ on client if there is a collision -(sent in the following slot)} \\ -\textit{$cr_{p_{last}}$ = saved cr entry $\tuple{s,id}$ on client if there is a -collision in reinserting the last slot (sent in the following slot)} \\ +%\textit{$cr_p$ = saved cr entry $\tuple{s,id}$ on client if there is a collision +%(sent in the following slot)} \\ +%\textit{$cr_{p_{last}}$ = saved cr entry $\tuple{s,id}$ on client if there is a +%collision in reinserting the last slot (sent in the following slot)} \\ \textit{$ck_p$ = counter of $kv \in KV$ for putting pairs (initially 0)} \\ \textit{$ck_g$ = counter of $kv \in KV$ for getting pairs (initially 0)} \\ \textit{$cs_p$ = counter of $ss \in SS$ for putting pairs (initially 0)} \\ @@ -593,6 +588,22 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \EndFunction \end{algorithmic} +\begin{algorithmic}[1] +\Function{PutSSPair}{$SS_s,\tuple{id_s,s_{s_{last}}}$}\Comment{Insert a set of $ss$ entries} +\State $SS_s \gets SS_s \cup \{\tuple{cs_p, \tuple{id_s,s_{s_{last}}}}\}$ +\State $cs_p \gets cs_p + 1$ +\State \Return{$SS_s$} +\EndFunction +\end{algorithmic} + +\begin{algorithmic}[1] +\Function{PutCRPair}{$CR_s,\tuple{s_s,id_s}$}\Comment{Insert a set of $cr$ entries} +\State $CR_s \gets CR_s \cup \{\tuple{cc_p, \tuple{s_s,id_s}}\}$ +\State $cc_p \gets cc_p + 1$ +\State \Return{$CR_s$} +\EndFunction +\end{algorithmic} + \begin{algorithmic}[1] \Function{CheckResize}{$MS_s,th_s,max_t,m'_s$} \State $s_{last_{min}} \gets MinLastSeqN(MS_s)$ @@ -609,7 +620,7 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \end{algorithmic} \begin{algorithmic}[1] -\Function{CheckNeedSS}{$MS_s,max_t$}\Comment{Check if $ss$ is needed} +\Function{CheckSLFull}{$MS_s,max_t$}\Comment{Check if $ss$ is needed} \State $s_{last_{min}} \gets MinLastSeqN(MS_s)$ \State $s_{last_{max}} \gets MaxLastSeqN(MS_s)$ \State $n_{live} \gets s_{last_{max}} - s_{last_{min}}$\Comment{Number of live slots} @@ -696,49 +707,16 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \EndFunction \end{algorithmic} -%\begin{algorithmic}[1] -%\Function{AddSlotSeq}{$DE_s,SS_s,cp_s$}\Comment{Insert a $ss$} -%\State $DE_{ret} \gets DE_s \cup SS_s$ -%\State $cp_s \gets cp_s - |SS_s|$ -%\State \Return{$\tuple{DE_{ret},cp_s}$} -%\EndFunction -%\end{algorithmic} - -\begin{algorithmic}[1] -\Function{PutSSPair}{$SS_s,\tuple{id_s,s_{s_{last}}}$}\Comment{Insert a set of $ss$ entries} -\State $SS_s \gets SS_s \cup \{\tuple{cs_p, \tuple{id_s,s_{s_{last}}}}\}$ -\State $cs_p \gets cs_p + 1$ -\State \Return{$SS_s$} -\EndFunction -\end{algorithmic} - -\begin{algorithmic}[1] -\Function{PutCRPair}{$CR_s,\tuple{s_s,id_s}$}\Comment{Insert a set of $cr$ entries} -\State $CR_s \gets CR_s \cup \{\tuple{cc_p, \tuple{s_s,id_s}}\}$ -\State $cc_p \gets cc_p + 1$ -\State \Return{$CR_s$} -\EndFunction -\end{algorithmic} - \begin{algorithmic}[1] \Function{AddQueSta}{$DE_s,max'_s,cp_s$}\Comment{Insert a $qs$} \State $DE_{ret} \gets \emptyset$ \State $qs_s \gets max'_s$ -\State $DE_{ret} \gets DE_s \cup qs_s$ +\State $DE_{ret} \gets DE_s \cup \{qs_s\}$ \State $cp_s \gets cp_s - 1$ \State \Return{$\tuple{DE_{ret},cp_s}$} \EndFunction \end{algorithmic} -%\begin{algorithmic}[1] -%\Function{AddColRes}{$DE_s,CR_s,cp_s$}\Comment{Insert a $cr$} -%\State $DE_{ret} \gets \emptyset$ -%\State $DE_{ret} \gets DE_s \cup CR_s$ -%\State $cp_s \gets cp_s - |CR_s|$ -%\State \Return{$\tuple{DE_{ret},cp_s}$} -%\EndFunction -%\end{algorithmic} - \begin{algorithmic}[1] \Function{GetKVPairs}{$DE_s,KV_s,cp_s$} \State $DE_{ret} \gets \emptyset$ @@ -760,12 +738,13 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \If{$|SS_s| \leq cp_s$}\Comment{$SS$ set can span multiple slots} \State $DE_{ret} \gets DE_s \cup \{\tuple{id_s,s_{s_{last}}} \mid \tuple{cs_s,\tuple{id_s,s_{s_{last}}}} \in SS_s\}$ + \State $cp_s \gets cp_s - |SS_s|$ \Else \State $DE_{ret} \gets DE_s \cup \{\tuple{id_s,s_{s_{last}}} \mid \tuple{cs_s,\tuple{id_s,s_{s_{last}}}} \in SS_s, cs_g \leq cs_s < cs_g + cp_s\}$ + \State $cp_s \gets 0$ \EndIf -\State $cp_s \gets cp_s - |SS_s|$ \State \Return{$\tuple{DE_{ret},cp_s}$} \EndFunction \end{algorithmic} @@ -776,12 +755,13 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \If{$|CR_s| \leq cp_s$}\Comment{$CR$ set can span multiple slots} \State $DE_{ret} \gets DE_s \cup \{\tuple{s_s,id_s} \mid \tuple{cc_s,\tuple{s_s,id_s}} \in CR_s\}$ + \State $cp_s \gets cp_s - |CR_s|$ \Else \State $DE_{ret} \gets DE_s \cup \{\tuple{s_s,id_s} \mid \tuple{cc_s,\tuple{s_s,id_s}} \in CR_s, cc_g \leq cc_s < cc_g + cp_s\}$ + \State $cp_s \gets 0$ \EndIf -\State $cp_s \gets cp_s - |CR_s|$ \State \Return{$\tuple{DE_{ret},cp_s}$} \EndFunction \end{algorithmic} @@ -795,8 +775,9 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \State $s_p \gets MaxLastSeqN(MS)$ \State $cp_p \gets cp$ \State $max'_p \gets \Call{CheckResize}{MS,th_p,max_g,m'_p}$ - \If{$max'_p \neq \emptyset$} - \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max'_p,cp_p}$\Comment{Add qs} + \If{$max'_p \neq \emptyset$}\Comment{Add a qs entry} + \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max'_p,cp_p}$ + \State $reinsert_{qs} \gets false$ \Else\Comment{Check if there is $qs$ reinsertion} \If{$reinsert_{qs}$} \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max_g,cp_p}$ @@ -821,8 +802,9 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \State $CR \gets \Call{PutCRPair}{CR,\tuple{s_{p_{col}},id_{p_{col}}}}$ \EndIf \EndWhile -\If{$|DE_p| = cp$}\Comment{Middle of set} - \State $ck_g \gets ck_g + cp_s$ +\State $MS \gets \Call{UpdateLastSeqN}{id_{self},s_p,MS}$ +\If{$|DE_p| = cp$}\Comment{Update set counters} + \State $ck_g \gets ck_g + cp_p$\Comment{Middle of set} \State $cs_g \gets cs_g + |SS|$ \State $cc_g \gets cc_g + |CR|$ \Else\Comment{End of set} @@ -830,10 +812,9 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \State $cs_g \gets 0$ \State $cc_g \gets 0$ \EndIf -\State $MS \gets \Call{UpdateLastSeqN}{id_{self},s_p,MS}$ -\State $need_p \gets \Call{CheckNeedSS}{MS,max_g}$ -\If{$need_p$} - \State $\Call{CheckLastSlot}{sl_{last}}$\Comment{Get ready to expunge first slot} +\State $need_p \gets \Call{CheckSLFull}{MS,max_g}$ +\If{$need_p$}\Comment{SL on server is full} + \State $\Call{CheckLastSlot}{sl_{last}}$\Comment{Salvage entries from expunged slot} \State $ss_p \gets \Call{CreateSlotSeq}{sl_{last}}$ \State $\tuple{id_p,s_{p_{last}}} \gets GetSS(ss_p)$ \State $SS \gets \Call{PutSSPair}{SS,\tuple{id_p,s_{p_{last}}}}$\Comment{Add ss}