Skip to content

Testing, Peer without Syncer #13

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

meri-leeworthy
Copy link

I initially factored out component, entity and peer, then merged the main branch and undid those changes, then redid them 😅

I was trying to set up a Peer just locally so as to get storage working on a local peer without setting up any Syncer1s, which doesn't work currently. I'm not 100% sure about the way I rewrote it - I have been getting a null pointer bug which is possibly related, and I added some tests which are currently failing for the same reason. So just opening this for now and going to try to see if I can get the tests passing! Also would appreciate any feedback re commit and PR conventions etc as I'm most experienced working solo...

@zicklag
Copy link
Contributor

zicklag commented Jun 6, 2025

If I'm understanding correctly, the peer does work fine with local storage without a syncer:

import process from "node:process";
import {
  EntityIdStr,
  Peer,
  StorageManager,
} from "@muni-town/leaf";
import { nodeFsStorageAdapter } from "@muni-town/leaf-storage-node-fs";
import { Name } from "./components";

const peer1 = new Peer(
  new StorageManager(nodeFsStorageAdapter("data/peer1")),
);

const id = (process.argv[2] as EntityIdStr) || undefined;
const ent1 = await peer1.open(id);
console.log("ID", ent1.id.toString());
console.log("Value1", ent1.doc.toJSON());

ent1.getOrInit(Name, (name) => name.set("first", "John"));
ent1.commit();

Running that example and then passing it the printed ID on the second run will load the entity data stored in the first run.


Unless you mean you want it to work even if it can't connect to the syncserver, which definitely is broken.

Another thing to consider is that we may not want to do any more work on Leaf as it is until we can integrate Keyhive. ( I heard someone was doing some testing with Keyhive, so maybe it's close enough that we con start testing it out already. )

I think most of this will have to change quite a bit with Keyhive, and it will replace all of our syncing logic.


Overall the split out looks good, though. 👍

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

Successfully merging this pull request may close these issues.

2 participants