CAT-K7: every operation's event is sent once, after a restart too
An event of a change carries the record, the version it follows and the event as its message id; the last version sent per record is a key of the state sent; at start the events of the operations after it are sent again under the same ids, so a stop between an operation and its event loses none and a second start sends none. Issue 1966. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -312,6 +312,8 @@ func operationFor(old *Entry, v Version, current bool) string {
|
||||
}
|
||||
prev, next := old.Working(), v.Record
|
||||
switch {
|
||||
case prev.Status == StatusReserved && next.Status == StatusProposed:
|
||||
return OpPropose
|
||||
case next.Status == StatusWithdrawn && prev.Status != StatusWithdrawn:
|
||||
return OpWithdraw
|
||||
case next.Accepted() && !prev.Accepted(), next.Status == StatusSuperseded && prev.Status != StatusSuperseded:
|
||||
@@ -567,3 +569,29 @@ func (s *ledgerStore) Untold(_ context.Context, key string) error {
|
||||
}
|
||||
|
||||
func isChanged(err error) bool { return errors.Is(err, stdio.ErrChanged) }
|
||||
|
||||
// Operations are the operations of a record that made a version (OperationReader).
|
||||
func (s *ledgerStore) Operations(_ context.Context, k Key) ([]OperationInfo, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
var out []OperationInfo
|
||||
for from := uint64(0); ; {
|
||||
var page buscalls.HistoryPage
|
||||
if err := s.pipe.Call(buscalls.LedgerHistory, buscalls.HistoryRequest{Ledger: LedgerName, Instance: InstanceOf(k), From: from}, &page); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, op := range page.Operations {
|
||||
var body struct {
|
||||
Version *versionHead `json:"version"`
|
||||
}
|
||||
if op.Operation == OpWriteSection || json.Unmarshal(op.Body, &body) != nil || body.Version == nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, OperationInfo{Sequence: op.Sequence, Operation: op.Operation, Version: body.Version.N, By: body.Version.By, At: body.Version.At, Why: body.Version.Why})
|
||||
}
|
||||
if page.Next == 0 {
|
||||
return out, nil
|
||||
}
|
||||
from = page.Next
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user