autobee 1.0.10 → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,6 +215,7 @@ const OplogMessageV1 = {
215
215
  throw new Error('Encoding not supported')
216
216
  },
217
217
  decode(state) {
218
+ c.uint.decode(state) // version
218
219
  const maxSupportedVersion = c.uint.decode(state)
219
220
 
220
221
  const flags = c.uint.decode(state)
@@ -245,6 +246,7 @@ const OplogMessageV0 = {
245
246
  throw new Error('Encoding not supported')
246
247
  },
247
248
  decode(state) {
249
+ c.uint.decode(state) // version
248
250
  const flags = c.uint.decode(state)
249
251
 
250
252
  const isCheckpointer = (flags & 1) !== 0
@@ -288,13 +290,12 @@ const SystemWriterV0 = {
288
290
  function infoLegacyMap(info) {
289
291
  return {
290
292
  version: info.version,
291
- members: info.members,
292
- pendingIndexers: info.pendingIndexers,
293
- indexers: info.indexers,
294
- heads: info.heads,
293
+ timestamp: 0,
294
+ flushes: 0,
295
+ view: null,
295
296
  views: info.views,
296
- encryptionLength: 0,
297
- entropy: null
297
+ heads: info.heads,
298
+ indexers: info.indexers
298
299
  }
299
300
  }
300
301
 
@@ -557,18 +557,29 @@ const encoding19 = {
557
557
  // @autobee/system-writer-v4
558
558
  const encoding20 = {
559
559
  preencode(state, m) {
560
- state.end++ // max flag is 2 so always one byte
560
+ state.end++ // max flag is 16 so always one byte
561
561
  c.uint.preencode(state, m.weight)
562
+ c.uint.preencode(state, m.maxWeight)
562
563
  c.uint.preencode(state, m.length)
563
564
  c.uint.preencode(state, m.clock)
565
+
566
+ if (m.timestamp) c.int.preencode(state, m.timestamp)
564
567
  },
565
568
  encode(state, m) {
566
- const flags = (m.isRemoved ? 1 : 0) | (m.isOplog ? 2 : 0)
569
+ const flags =
570
+ (m.isRemoved ? 1 : 0) |
571
+ (m.isOplog ? 2 : 0) |
572
+ (m.isGenesis ? 4 : 0) |
573
+ (m.isAnchor ? 8 : 0) |
574
+ (m.timestamp ? 16 : 0)
567
575
 
568
576
  c.uint.encode(state, flags)
569
577
  c.uint.encode(state, m.weight)
578
+ c.uint.encode(state, m.maxWeight)
570
579
  c.uint.encode(state, m.length)
571
580
  c.uint.encode(state, m.clock)
581
+
582
+ if (m.timestamp) c.int.encode(state, m.timestamp)
572
583
  },
573
584
  decode(state) {
574
585
  const v = c.uint.decode(state)
@@ -579,8 +590,12 @@ const encoding20 = {
579
590
  isRemoved: (flags & 1) !== 0,
580
591
  isOplog: (flags & 2) !== 0,
581
592
  weight: c.uint.decode(state),
593
+ maxWeight: c.uint.decode(state),
582
594
  length: c.uint.decode(state),
583
- clock: c.uint.decode(state)
595
+ clock: c.uint.decode(state),
596
+ isGenesis: (flags & 4) !== 0,
597
+ isAnchor: (flags & 8) !== 0,
598
+ timestamp: (flags & 16) !== 0 ? c.int.decode(state) : 0
584
599
  }
585
600
  }
586
601
  }
@@ -749,35 +764,128 @@ const encoding25_inline = {
749
764
  }
750
765
  }
751
766
 
752
- // @autobee/oplog-message-v3
767
+ // @autobee/signed-backer
753
768
  const encoding26 = {
769
+ preencode(state, m) {
770
+ c.fixed32.preencode(state, m.key)
771
+ c.uint.preencode(state, m.length)
772
+ c.fixed64.preencode(state, m.signature)
773
+ c.buffer.preencode(state, m.manifest)
774
+ },
775
+ encode(state, m) {
776
+ c.fixed32.encode(state, m.key)
777
+ c.uint.encode(state, m.length)
778
+ c.fixed64.encode(state, m.signature)
779
+ c.buffer.encode(state, m.manifest)
780
+ },
781
+ decode(state) {
782
+ const r0 = c.fixed32.decode(state)
783
+ const r1 = c.uint.decode(state)
784
+ const r2 = c.fixed64.decode(state)
785
+ const r3 = c.buffer.decode(state)
786
+
787
+ return {
788
+ key: r0,
789
+ length: r1,
790
+ signature: r2,
791
+ manifest: r3
792
+ }
793
+ }
794
+ }
795
+
796
+ // @autobee/witness.backer
797
+ const encoding27_1 = c.frame(encoding26)
798
+
799
+ // @autobee/witness
800
+ const encoding27 = {
801
+ preencode(state, m) {
802
+ c.uint.preencode(state, m.weight)
803
+ encoding27_1.preencode(state, m.backer)
804
+ },
805
+ encode(state, m) {
806
+ c.uint.encode(state, m.weight)
807
+ encoding27_1.encode(state, m.backer)
808
+ },
809
+ decode(state) {
810
+ const r0 = c.uint.decode(state)
811
+ const r1 = encoding27_1.decode(state)
812
+
813
+ return {
814
+ weight: r0,
815
+ backer: r1
816
+ }
817
+ }
818
+ }
819
+
820
+ // @autobee/attestation
821
+ const encoding28 = {
822
+ preencode(state, m) {
823
+ c.fixed32.preencode(state, m.key)
824
+ c.uint.preencode(state, m.weight)
825
+ c.fixed64.preencode(state, m.signature)
826
+ },
827
+ encode(state, m) {
828
+ c.fixed32.encode(state, m.key)
829
+ c.uint.encode(state, m.weight)
830
+ c.fixed64.encode(state, m.signature)
831
+ },
832
+ decode(state) {
833
+ const r0 = c.fixed32.decode(state)
834
+ const r1 = c.uint.decode(state)
835
+ const r2 = c.fixed64.decode(state)
836
+
837
+ return {
838
+ key: r0,
839
+ weight: r1,
840
+ signature: r2
841
+ }
842
+ }
843
+ }
844
+
845
+ // @autobee/oplog-message-v3.witness
846
+ const encoding29_6 = c.frame(encoding27)
847
+ // @autobee/oplog-message-v3.attestations
848
+ const encoding29_7 = c.array(c.frame(encoding28))
849
+
850
+ // @autobee/oplog-message-v3
851
+ const encoding29 = {
754
852
  preencode(state, m) {
755
853
  c.uint.preencode(state, m.timestamp)
756
- encoding26_1.preencode(state, m.links)
757
- state.end++ // max flag is 16 so always one byte
854
+ encoding29_1.preencode(state, m.links)
855
+ state.end++ // max flag is 64 so always one byte
758
856
 
759
857
  if (m.batch) encoding24.preencode(state, m.batch)
760
858
  if (m.views) encoding25_inline.preencode(state, m.views)
761
859
  if (m.value) c.buffer.preencode(state, m.value)
860
+ if (m.witness) encoding29_6.preencode(state, m.witness)
861
+ if (m.attestations) encoding29_7.preencode(state, m.attestations)
762
862
  },
763
863
  encode(state, m) {
764
- let flags = (m.batch ? 1 : 0) | (m.views ? 2 : 0) | (m.optimistic ? 8 : 0) | (m.value ? 16 : 0)
864
+ let flags =
865
+ (m.batch ? 1 : 0) |
866
+ (m.views ? 2 : 0) |
867
+ (m.optimistic ? 8 : 0) |
868
+ (m.value ? 16 : 0) |
869
+ (m.witness ? 32 : 0) |
870
+ (m.attestations ? 64 : 0)
765
871
  if (m.views) {
766
872
  flags |= m.views.view ? 4 : 0
767
873
  }
768
874
 
769
875
  c.uint.encode(state, m.timestamp)
770
- encoding26_1.encode(state, m.links)
876
+ encoding29_1.encode(state, m.links)
771
877
  c.uint.encode(state, flags)
772
878
 
773
879
  if (m.batch) encoding24.encode(state, m.batch)
774
880
  if (m.views) encoding25_inline.encode(state, m.views)
775
881
  if (m.value) c.buffer.encode(state, m.value)
882
+ if (m.witness) encoding29_6.encode(state, m.witness)
883
+ if (m.attestations) encoding29_7.encode(state, m.attestations)
776
884
  },
777
885
  decode(state) {
778
886
  const v = c.uint.decode(state)
779
887
  const r0 = c.uint.decode(state)
780
- const r1 = encoding26_1.decode(state)
888
+ const r1 = encoding29_1.decode(state)
781
889
  const flags = c.uint.decode(state)
782
890
 
783
891
  return {
@@ -787,13 +895,15 @@ const encoding26 = {
787
895
  batch: (flags & 1) !== 0 ? encoding24.decode(state) : null,
788
896
  views: (flags & 2) !== 0 ? encoding25_inline.decode(state, flags >>> 2) : null,
789
897
  optimistic: (flags & 8) !== 0,
790
- value: (flags & 16) !== 0 ? c.buffer.decode(state) : null
898
+ value: (flags & 16) !== 0 ? c.buffer.decode(state) : null,
899
+ witness: (flags & 32) !== 0 ? encoding29_6.decode(state) : null,
900
+ attestations: (flags & 64) !== 0 ? encoding29_7.decode(state) : null
791
901
  }
792
902
  }
793
903
  }
794
904
 
795
905
  // @autobee/oplog
796
- const encoding27 = {
906
+ const encoding30 = {
797
907
  preencode(state, m) {
798
908
  c.uint.preencode(state, m.version)
799
909
  switch (m.version) {
@@ -807,7 +917,7 @@ const encoding27 = {
807
917
  encoding14.preencode(state, m)
808
918
  break
809
919
  case 3:
810
- encoding26.preencode(state, m)
920
+ encoding29.preencode(state, m)
811
921
  break
812
922
  default:
813
923
  throw new Error('Unsupported version')
@@ -826,7 +936,7 @@ const encoding27 = {
826
936
  encoding14.encode(state, m)
827
937
  break
828
938
  case 3:
829
- encoding26.encode(state, m)
939
+ encoding29.encode(state, m)
830
940
  break
831
941
  default:
832
942
  throw new Error('Unsupported version')
@@ -850,7 +960,7 @@ const encoding27 = {
850
960
  return decoded
851
961
  }
852
962
  case 3: {
853
- const decoded = encoding26.decode(state)
963
+ const decoded = encoding29.decode(state)
854
964
  return decoded
855
965
  }
856
966
  default:
@@ -860,7 +970,7 @@ const encoding27 = {
860
970
  }
861
971
 
862
972
  // @autobee/manifest-data
863
- const encoding28 = {
973
+ const encoding31 = {
864
974
  preencode(state, m) {
865
975
  c.uint.preencode(state, m.version)
866
976
  state.end++ // max flag is 2 so always one byte
@@ -894,7 +1004,7 @@ const encoding18_3 = c.array(encoding22)
894
1004
  // @autobee/system-info-v3.indexers, deferred due to recusive use
895
1005
  const encoding18_4 = encoding18_3
896
1006
  // @autobee/oplog-message-v3.links, deferred due to recusive use
897
- const encoding26_1 = encoding18_3
1007
+ const encoding29_1 = encoding18_3
898
1008
 
899
1009
  function setVersion(v) {
900
1010
  version = v
@@ -971,12 +1081,18 @@ function getEncoding(name) {
971
1081
  return encoding24
972
1082
  case '@autobee/views':
973
1083
  return encoding25
974
- case '@autobee/oplog-message-v3':
1084
+ case '@autobee/signed-backer':
975
1085
  return encoding26
976
- case '@autobee/oplog':
1086
+ case '@autobee/witness':
977
1087
  return encoding27
978
- case '@autobee/manifest-data':
1088
+ case '@autobee/attestation':
979
1089
  return encoding28
1090
+ case '@autobee/oplog-message-v3':
1091
+ return encoding29
1092
+ case '@autobee/oplog':
1093
+ return encoding30
1094
+ case '@autobee/manifest-data':
1095
+ return encoding31
980
1096
  default:
981
1097
  throw new Error('Encoder not found ' + name)
982
1098
  }
@@ -476,6 +476,12 @@
476
476
  "type": "uint",
477
477
  "version": 1
478
478
  },
479
+ {
480
+ "name": "maxWeight",
481
+ "required": true,
482
+ "type": "uint",
483
+ "version": 1
484
+ },
479
485
  {
480
486
  "name": "length",
481
487
  "required": true,
@@ -487,6 +493,24 @@
487
493
  "required": true,
488
494
  "type": "uint",
489
495
  "version": 1
496
+ },
497
+ {
498
+ "name": "isGenesis",
499
+ "required": false,
500
+ "type": "bool",
501
+ "version": 1
502
+ },
503
+ {
504
+ "name": "isAnchor",
505
+ "required": false,
506
+ "type": "bool",
507
+ "version": 1
508
+ },
509
+ {
510
+ "name": "timestamp",
511
+ "required": false,
512
+ "type": "int",
513
+ "version": 1
490
514
  }
491
515
  ]
492
516
  },
@@ -598,6 +622,84 @@
598
622
  }
599
623
  ]
600
624
  },
625
+ {
626
+ "name": "signed-backer",
627
+ "namespace": "autobee",
628
+ "compact": false,
629
+ "flagsPosition": -1,
630
+ "fields": [
631
+ {
632
+ "name": "key",
633
+ "required": true,
634
+ "type": "fixed32",
635
+ "version": 1
636
+ },
637
+ {
638
+ "name": "length",
639
+ "required": true,
640
+ "type": "uint",
641
+ "version": 1
642
+ },
643
+ {
644
+ "name": "signature",
645
+ "required": true,
646
+ "type": "fixed64",
647
+ "version": 1
648
+ },
649
+ {
650
+ "name": "manifest",
651
+ "required": true,
652
+ "type": "buffer",
653
+ "version": 1
654
+ }
655
+ ]
656
+ },
657
+ {
658
+ "name": "witness",
659
+ "namespace": "autobee",
660
+ "compact": false,
661
+ "flagsPosition": -1,
662
+ "fields": [
663
+ {
664
+ "name": "weight",
665
+ "required": true,
666
+ "type": "uint",
667
+ "version": 1
668
+ },
669
+ {
670
+ "name": "backer",
671
+ "required": true,
672
+ "type": "@autobee/signed-backer",
673
+ "version": 1
674
+ }
675
+ ]
676
+ },
677
+ {
678
+ "name": "attestation",
679
+ "namespace": "autobee",
680
+ "compact": false,
681
+ "flagsPosition": -1,
682
+ "fields": [
683
+ {
684
+ "name": "key",
685
+ "required": true,
686
+ "type": "fixed32",
687
+ "version": 1
688
+ },
689
+ {
690
+ "name": "weight",
691
+ "required": true,
692
+ "type": "uint",
693
+ "version": 1
694
+ },
695
+ {
696
+ "name": "signature",
697
+ "required": true,
698
+ "type": "fixed64",
699
+ "version": 1
700
+ }
701
+ ]
702
+ },
601
703
  {
602
704
  "name": "oplog-message-v3",
603
705
  "namespace": "autobee",
@@ -637,6 +739,17 @@
637
739
  "name": "value",
638
740
  "type": "buffer",
639
741
  "version": 1
742
+ },
743
+ {
744
+ "name": "witness",
745
+ "type": "@autobee/witness",
746
+ "version": 1
747
+ },
748
+ {
749
+ "name": "attestations",
750
+ "array": true,
751
+ "type": "@autobee/attestation",
752
+ "version": 1
640
753
  }
641
754
  ]
642
755
  },