hypercore 10.32.2 → 10.32.3
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.
- package/lib/messages.js +25 -1
- package/lib/verifier.js +3 -2
- package/package.json +1 -1
package/lib/messages.js
CHANGED
|
@@ -87,6 +87,11 @@ const manifestv0 = {
|
|
|
87
87
|
hashes.preencode(state, m.hash)
|
|
88
88
|
state.end++ // type
|
|
89
89
|
|
|
90
|
+
if (m.prologue && m.signers.length === 0) {
|
|
91
|
+
c.fixed32.preencode(state, m.prologue.hash)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
if (m.quorum === 1 && m.signers.length === 1 && !m.allowPatch) {
|
|
91
96
|
signer.preencode(state, m.signers[0])
|
|
92
97
|
} else {
|
|
@@ -98,6 +103,12 @@ const manifestv0 = {
|
|
|
98
103
|
encode (state, m) {
|
|
99
104
|
hashes.encode(state, m.hash)
|
|
100
105
|
|
|
106
|
+
if (m.prologue && m.signers.length === 0) {
|
|
107
|
+
c.uint.encode(state, 0)
|
|
108
|
+
c.fixed32.encode(state, m.prologue.hash)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
if (m.quorum === 1 && m.signers.length === 1 && !m.allowPatch) {
|
|
102
113
|
c.uint.encode(state, 1)
|
|
103
114
|
signer.encode(state, m.signers[0])
|
|
@@ -112,9 +123,22 @@ const manifestv0 = {
|
|
|
112
123
|
const hash = hashes.decode(state)
|
|
113
124
|
const type = c.uint.decode(state)
|
|
114
125
|
|
|
115
|
-
if (type === 0) throw new Error('Type 0 is deprecated')
|
|
116
126
|
if (type > 2) throw new Error('Unknown type: ' + type)
|
|
117
127
|
|
|
128
|
+
if (type === 0) {
|
|
129
|
+
return {
|
|
130
|
+
version: 0,
|
|
131
|
+
hash,
|
|
132
|
+
allowPatch: false,
|
|
133
|
+
quorum: 0,
|
|
134
|
+
signers: [],
|
|
135
|
+
prologue: {
|
|
136
|
+
hash: c.fixed32.decode(state),
|
|
137
|
+
length: 0
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
118
142
|
if (type === 1) {
|
|
119
143
|
return {
|
|
120
144
|
version: 0,
|
package/lib/verifier.js
CHANGED
|
@@ -208,8 +208,9 @@ function toMap (nodes) {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
function defaultQuorum (man) {
|
|
211
|
-
if (
|
|
212
|
-
|
|
211
|
+
if (typeof man.quorum === 'number') return man.quorum
|
|
212
|
+
if (!man.signers || !man.signers.length) return 0
|
|
213
|
+
return (man.signers.length >> 1) + 1
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
function generateUpgrade (patch, start, length) {
|