this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update data_version after each batch

garrison 2ebd5567 171086e1

+15 -7
+15 -7
lib/servers/storage.ex
··· 547 547 assert result.start_version == (state.data_version + 1) 548 548 assert result.end_version >= state.data_version 549 549 550 - state = apply_batches(state, result.batches) 550 + state = do_apply_batches(result.batches, state) 551 551 SimProcess.send_after self(), :peek_retry, 1 552 552 553 553 # Update KCV ··· 563 563 %{state | data_version: result.end_version, peek_nonce: nil} 564 564 end 565 565 566 - defp apply_batches(%State{} = state, batches) when is_list(batches) do 567 - Enum.reduce(batches, state, fn {commit_version, mutations}, %State{} = state -> 568 - # TODO: update state.data_version after each batch? 569 - apply_batch(state, commit_version, mutations) 570 - end) 566 + @spec do_apply_batches(list, State.t) :: State.t 567 + defp do_apply_batches([], %State{} = state), do: state 568 + 569 + defp do_apply_batches([batch | batches_rest], %State{} = state) do 570 + {commit_version, mutations} = batch 571 + assert is_integer(commit_version) 572 + assert commit_version >= 0 573 + assert is_list(mutations) 574 + 575 + state = apply_batch(state, commit_version, mutations) 576 + assert state.data_version == commit_version 577 + 578 + do_apply_batches(batches_rest, state) 571 579 end 572 580 573 581 @spec apply_batch(%State{}, non_neg_integer, [Utils.mutation]) :: %State{} ··· 586 594 ] 587 595 588 596 :ok = XKS.apply_partitioned_batches(state.xks, commit_version, partitioned_batches) 589 - state 597 + %{state | data_version: commit_version} 590 598 end 591 599 592 600 defp handle_special_mutations(%State{} = state, version, mutations) do