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

Fixing vertex dependencies issue #247

Merged
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function topologyMessagesHandler(

switch (message.type) {
case NetworkPb.Message_MessageType.UPDATE:
updateHandler(node, message.data);
updateHandler(node, message.data, message.sender);
break;
case NetworkPb.Message_MessageType.SYNC:
if (!stream) {
Expand Down Expand Up @@ -71,14 +71,20 @@ export async function topologyMessagesHandler(
data: { id: string, operations: {nonce: string, fn: string, args: string[] }[] }
operations array doesn't contain the full remote operations array
*/
function updateHandler(node: TopologyNode, data: Uint8Array) {
async function updateHandler(
node: TopologyNode,
data: Uint8Array,
senderPeerId: string,
) {
const updateMessage = NetworkPb.Update.decode(data);
d-roak marked this conversation as resolved.
Show resolved Hide resolved
const object = node.objectStore.get(updateMessage.objectId);
if (!object) {
console.error("topology::node::updateHandler", "Object not found");
return false;
}

await node.syncObject(updateMessage.objectId, senderPeerId);
d-roak marked this conversation as resolved.
Show resolved Hide resolved

object.merge(
updateMessage.vertices.map((v) => {
return {
Expand All @@ -92,6 +98,7 @@ function updateHandler(node: TopologyNode, data: Uint8Array) {
};
}),
);

node.objectStore.put(object.id, object);

return true;
Expand Down Expand Up @@ -147,7 +154,7 @@ function syncHandler(
data: { id: string, operations: {nonce: string, fn: string, args: string[] }[] }
operations array contain the full remote operations array
*/
function syncAcceptHandler(
async function syncAcceptHandler(
node: TopologyNode,
protocol: string,
sender: string,
Expand All @@ -173,6 +180,7 @@ function syncAcceptHandler(
});

if (vertices.length !== 0) {
await node.syncObject(object.id, sender);
d-roak marked this conversation as resolved.
Show resolved Hide resolved
object.merge(vertices);
node.objectStore.put(object.id, object);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.3.0";
export const VERSION = "0.3.1";
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.