Skip to content

Commit

Permalink
refactor: semantics names
Browse files Browse the repository at this point in the history
  • Loading branch information
JanLewDev committed Sep 13, 2024
1 parent 53c8753 commit 657cfaa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/crdt/src/cros/AddWinsSet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
export class AddWinsSet<T> implements CRO {
operations: string[] = ["add", "remove"];
state: Map<T, boolean>;
semanticsType = SemanticsType.pairWise;
semanticsType = SemanticsType.pair;

constructor() {
this.state = new Map<T, boolean>();
Expand Down
2 changes: 1 addition & 1 deletion packages/crdt/src/cros/PseudoRandomWinsSet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function compute_hash(s: string): number {
export class PseudoRandomWinsSet<T> implements CRO {
operations: string[] = ["add", "remove"];
state: Map<T, boolean>;
semanticsType = SemanticsType.multiVertex;
semanticsType = SemanticsType.multiple;

constructor() {
this.state = new Map<T, boolean>();
Expand Down
16 changes: 8 additions & 8 deletions packages/object/src/hashgraph/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as crypto from "node:crypto";
import { linearizeMultiVertex } from "../linearize/multi-vertexSemantics.js";
import { linearizePairWise } from "../linearize/pair-wiseSemantics.js";
import { linearizeMultiple } from "../linearize/multiplesemantics.js";
import { linearizePair } from "../linearize/pairsemantics.js";
import { BitSet } from "./bitset.js";

export type Hash = string;
Expand All @@ -20,8 +20,8 @@ export enum ActionType {
}

export enum SemanticsType {
pairWise = 0,
multiVertex = 1,
pair = 0,
multiple = 1,
}

// In the case of multi-vertex semantics, we are returning an array of vertices (their hashes) to be reduced.
Expand Down Expand Up @@ -200,10 +200,10 @@ export class HashGraph {

linearizeOperations(): Operation[] {
switch (this.semanticsType) {
case SemanticsType.pairWise:
return linearizePairWise(this);
case SemanticsType.multiVertex:
return linearizeMultiVertex(this);
case SemanticsType.pair:
return linearizePair(this);
case SemanticsType.multiple:
return linearizeMultiple(this);
default:
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type Vertex,
} from "../hashgraph/index.js";

export function linearizeMultiVertex(hashGraph: HashGraph): Operation[] {
export function linearizeMultiple(hashGraph: HashGraph): Operation[] {
let order = hashGraph.topologicalSort(true);
const indices: Map<Hash, number> = new Map();
const result: Operation[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type Operation,
} from "../hashgraph/index.js";

export function linearizePairWise(hashGraph: HashGraph): Operation[] {
export function linearizePair(hashGraph: HashGraph): Operation[] {
const order = hashGraph.topologicalSort(true);
const result: Operation[] = [];
let i = 0;
Expand Down

0 comments on commit 657cfaa

Please sign in to comment.