import { Box } from './classes/box.js'; import { Scene } from './classes/scene.js'; import { Post } from './classes/post.js'; import { Member } from './classes/member.js'; import { ForumNode } from './classes/forum-node.js'; import { ForumNetwork } from './classes/forum-network.js'; import { delay } from './util.js'; const rootElement = document.getElementById('forum-network'); const rootBox = new Box('rootBox', rootElement).flex(); window.scene = new Scene('Forum test', rootBox).log('sequenceDiagram'); window.author1 = await new Member('author1', window.scene).initialize(); window.author2 = await new Member('author2', window.scene).initialize(); window.forumNetwork = new ForumNetwork(); window.forumNode1 = await new ForumNode('node1', window.scene).initialize(window.forumNetwork); window.forumNode2 = await new ForumNode('node2', window.scene).initialize(window.forumNetwork); window.forumNode3 = await new ForumNode('node3', window.scene).initialize(window.forumNetwork); const processInterval = setInterval(async () => { await window.forumNode1.processNextMessage(); await window.forumNode2.processNextMessage(); await window.forumNode3.processNextMessage(); await window.scene.renderSequenceDiagram(); }, 100); // const blockchain = new Blockchain(); window.post1 = new Post({ message: 'hi' }); window.post2 = new Post({ message: 'hello' }).addCitation(window.post1.id, 1.0); await delay(1000); await window.author1.submitPost(window.forumNode1, window.post1, 50); await delay(1000); await window.author2.submitPost(window.forumNode2, window.post2, 100); await delay(1000); clearInterval(processInterval);