git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit dca4a828fc87c8fdcf30901362c346ff179401d4

added pin

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 8/24/2017, 10:19:37 PM
Parent: 0a8350a93125e32b15276e387bc08d9e51610c0c

Files changed

index.jschanged
tests/index.jschanged
index.jsView
@@ -29,8 +29,9 @@
2929 this.creationService = new CreationService({
3030 hypervisor: this
3131 })
3232 this.scheduler.systemServices.set(CREATION_ID, this.creationService)
33+ this.pinnedIds = new Set()
3334
3435 this.ROOT_ID = 'zdpuAm6aTdLVMUuiZypxkwtA7sKm7BWERy8MPbaCrFsmiyzxr'
3536 }
3637
@@ -149,9 +150,9 @@
149150 async createStateRoot (ticks) {
150151 await this.scheduler.wait(ticks)
151152
152153 const unlinked = await DFSchecker(this.tree, this._nodesToCheck, (id) => {
153- return this.ROOT_ID === id
154+ return this.pinnedIds.has(id)
154155 })
155156 for (const id of unlinked) {
156157 await this.tree.delete(id)
157158 }
@@ -169,5 +170,9 @@
169170 Constructor: Constructor,
170171 args: args
171172 }
172173 }
174+
175+ pin (instance) {
176+ this.pinnedIds.add(instance.id)
177+ }
173178 }
tests/index.jsView
@@ -44,8 +44,10 @@
4444 type: testVMContainer.typeId
4545 }
4646 }))
4747
48+ hypervisor.pin(rootContainer)
49+
4850 const [portRef1, portRef2] = rootContainer.ports.createChannel()
4951 const initMessage = rootContainer.createMessage({
5052 data: {
5153 code: Buffer.from('test code'),
@@ -88,8 +90,10 @@
8890 data: {
8991 type: testVMContainer.typeId
9092 }
9193 }))
94+
95+ hypervisor.pin(root)
9296 const [portRef1, portRef2] = root.ports.createChannel()
9397
9498 await root.ports.bind('one', portRef1)
9599 await root.createInstance(root.createMessage({
@@ -157,8 +161,11 @@
157161 data: {
158162 type: testVMContainer.typeId
159163 }
160164 }))
165+
166+ hypervisor.pin(root)
167+
161168 const rootId = root.id
162169 const [portRef1, portRef2] = root.ports.createChannel()
163170 await root.createInstance(root.createMessage({
164171 data: {
@@ -243,8 +250,11 @@
243250 data: {
244251 type: Root.typeId
245252 }
246253 }))
254+
255+ hypervisor.pin(root)
256+
247257 await root.message(root.createMessage())
248258 const stateRoot = await hypervisor.createStateRoot()
249259
250260 t.deepEquals(stateRoot, {
@@ -335,8 +345,10 @@
335345 data: {
336346 type: Root.typeId
337347 }
338348 }))
349+
350+ hypervisor.pin(root)
339351 const [portRef1, portRef2] = root.ports.createChannel()
340352
341353 const message = root.createMessage()
342354 await Promise.all([
@@ -452,8 +464,11 @@
452464 data: {
453465 type: Root.typeId
454466 }
455467 }))
468+
469+ hypervisor.pin(root)
470+
456471 const [portRef1, portRef2] = root.ports.createChannel()
457472 const [portRef3, portRef4] = root.ports.createChannel()
458473
459474 const message = root.createMessage()
@@ -538,8 +553,11 @@
538553 data: {
539554 type: Root.typeId
540555 }
541556 }))
557+
558+ hypervisor.pin(root)
559+
542560 const [portRef1, portRef2] = root.ports.createChannel()
543561 await Promise.all([
544562 root.ports.bind('first', portRef1),
545563 root.createInstance(root.createMessage({
@@ -571,8 +589,10 @@
571589 type: BaseContainer.typeId
572590 }
573591 }))
574592
593+ hypervisor.pin(root)
594+
575595 const [portRef1, portRef2] = root.ports.createChannel()
576596 root.createInstance(root.createMessage({
577597 data: {
578598 type: BaseContainer.typeId
@@ -649,8 +669,11 @@
649669 data: {
650670 type: Root.typeId
651671 }
652672 }))
673+
674+ hypervisor.pin(root)
675+
653676 const [portRef1, portRef2] = root.ports.createChannel()
654677 await root.ports.bind('first', portRef1)
655678 await root.createInstance(root.createMessage({
656679 data: {
@@ -691,8 +714,11 @@
691714 data: {
692715 type: Root.typeId
693716 }
694717 }))
718+
719+ hypervisor.pin(root)
720+
695721 const [portRef1, portRef2] = root.ports.createChannel()
696722 await root.ports.bind('first', portRef1)
697723 await root.createInstance(root.createMessage({
698724 data: {
@@ -752,8 +778,11 @@
752778 data: {
753779 type: Root.typeId
754780 }
755781 }))
782+
783+ hypervisor.pin(root)
784+
756785 const [portRef1, portRef2] = root.ports.createChannel()
757786 await root.ports.bind('first', portRef1)
758787 await root.createInstance(root.createMessage({
759788 data: {
@@ -834,8 +863,11 @@
834863 data: {
835864 type: Root.typeId
836865 }
837866 }))
867+
868+ hypervisor.pin(root)
869+
838870 const [portRef1, portRef2] = root.ports.createChannel()
839871 await root.ports.bind('first', portRef1)
840872 await root.createInstance(root.createMessage({
841873 data: {
@@ -920,8 +952,10 @@
920952 type: Root.typeId
921953 }
922954 }))
923955
956+ hypervisor.pin(root)
957+
924958 const [portRef1, portRef2] = root.ports.createChannel()
925959 await Promise.all([
926960 root.ports.bind('first', portRef1),
927961 root.createInstance(root.createMessage({
@@ -958,17 +992,18 @@
958992 }
959993 }
960994
961995 const hypervisor = new Hypervisor(node.dag)
962-
963996 hypervisor.registerContainer(testVMContainer)
964997
965998 const rootContainer = await hypervisor.createInstance(new Message({
966999 data: {
9671000 type: testVMContainer.typeId
9681001 }
9691002 }))
9701003
1004+ hypervisor.pin(rootContainer)
1005+
9711006 const [portRef1, portRef2] = rootContainer.ports.createChannel()
9721007 const initMessage = rootContainer.createMessage({
9731008 data: {
9741009 type: testVMContainer.typeId
@@ -1063,15 +1098,17 @@
10631098 hypervisor.registerContainer(TestVMContainer2)
10641099
10651100 const port = hypervisor.creationService.getPort()
10661101
1067- await hypervisor.createInstance(new Message({
1102+ const root = await hypervisor.createInstance(new Message({
10681103 data: {
10691104 type: TestVMContainer.typeId
10701105 },
10711106 ports: [port]
10721107 }))
10731108
1109+ hypervisor.pin(root)
1110+
10741111 const stateRoot = await hypervisor.createStateRoot()
10751112 // await hypervisor.graph.tree(hypervisor.state, Infinity, true)
10761113 const expectedSR = {
10771114 '/': 'zdpuAonuhk7ZhdghJh4saaUCskY5mXZ6M9BcV9iAhCanAQx9i'

Built with git-ssb-web