Explorer

definy.snapshot-cache-resolve

description
Read the events from index as project snapshots, using the cached ones and decoding the others (definy.decode-stored-snapshot)
type
Fn(
  events: List<@definy.stored-event>,
  cached: List<@definy.snapshot-cache-entry>,
  index: Number,
  all: List<@definy.snapshot-cache-entry>,
  fresh: List<@definy.snapshot-cache-entry>
) -> @definy.snapshot-cache-resolution
expression
fn(events$0, cached$1, index$2, all$3, fresh$4) =>
  match @core.list-get(list: $0, index: $2) {
    #none(_) =>
      {all: $3, fresh: $4},
    #some(event$5) =>
      match @definy.snapshot-cache-find(entries: $1, event_hash: $5.event_hash, index: 0) {
        #some(entry$6) =>
          @definy.snapshot-cache-resolve(
            events: $0,
            cached: $1,
            index: @core.plus(left: $2, right: 1),
            all: @core.list-append(list: $3, item: $6),
            fresh: $4
          ),
        #none(_) =>
          let entry$7 = {
              event_hash: $5.event_hash,
              commit: @definy.decode-stored-snapshot(signed_event_bytes: $5.signed_event_bytes)
            };
          @definy.snapshot-cache-resolve(
            events: $0,
            cached: $1,
            index: @core.plus(left: $2, right: 1),
            all: @core.list-append(list: $3, item: $7),
            fresh: @core.list-append(list: $4, item: $7)
          )
      }
  }
visibility
public
definy.snapshot-cache-resolve (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: m80sGtH4HvdzxhYpAGhtA3o_iU3_7bXrPNSHKcZDnio
content hash: -QtrjqKHuVPCQOD3WamX8_tASN9y6PM2nF6_qnXivno