Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress TransactionUpdate #1355

Open
jeremybanka opened this issue Feb 6, 2024 · 0 comments
Open

Compress TransactionUpdate #1355

jeremybanka opened this issue Feb 6, 2024 · 0 comments

Comments

@jeremybanka
Copy link
Owner

jeremybanka commented Feb 6, 2024

TransactionUpdate is a lot bulkier than it has to be:

type TransactionUpdate = {
  id: string // specific to this transaction instance
  key: string // common to the transaction implementation
  epoch: number // serial number in continuity
  updates: (AtomUpdate | TransactionUpdate)[]
}
type AtomUpdate<T> = {
  key: string
  family?: {
    key: string
    subKey: Json.Serializable
  }
  newValue: T
  oldValue: T
}

This can be flattened:

type TransactionUpdate = [
  begin: "<$transaction_update>"
  epoch: number,
  id: string,
  key: string,
  ...([...TransactionUpdate] | [...AtomUpdate])[]
  close: ""
]
type AtomUpdate<T> = [
  type: "<a>"
  key: (string | [key: string, familyKey: string, familySubKey: Json.Serializable]),
  oldValue: T,
  newValue: T,
  type: "</a>"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant