@hive-p2p/browser 1.0.103 → 1.0.105
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/core/arbiter.mjs +4 -7
- package/core/config.mjs +4 -0
- package/hive-p2p.min.js +3 -3
- package/package.json +1 -1
- package/services/cryptos.mjs +2 -2
package/core/arbiter.mjs
CHANGED
|
@@ -5,11 +5,8 @@ import { NODE, GOSSIP, UNICAST, LOG_CSS } from './config.mjs';
|
|
|
5
5
|
// Growing each second by 1000ms until 0
|
|
6
6
|
// Lowered each second by 100ms until 0 (avoid attacker growing balances on multiple disconnected peers)
|
|
7
7
|
|
|
8
|
-
const BYTES_COUNT_PERIOD
|
|
9
|
-
const
|
|
10
|
-
const MAX_GOSSIP_BYTES_PER_PERIOD = 100_000; // 100KB per period
|
|
11
|
-
|
|
12
|
-
const MAX_TRUST = 3_600_000; // +3600 seconds = 1 hour of good behavior
|
|
8
|
+
const BYTES_COUNT_PERIOD = 10_000; // 10 seconds
|
|
9
|
+
const MAX_TRUST = 3_600_000; // +3600 seconds = 1 hour of good behavior
|
|
13
10
|
export const TRUST_VALUES = {
|
|
14
11
|
// POSITIVE IDENTITY
|
|
15
12
|
VALID_SIGNATURE: +10_000, // +10 seconds
|
|
@@ -90,8 +87,8 @@ export class Arbiter {
|
|
|
90
87
|
if (!this.bytesCounters[type][peerId]) this.bytesCounters[type][peerId] = 0;
|
|
91
88
|
this.bytesCounters[type][peerId] += byteLength;
|
|
92
89
|
const [maxByte, penality] = type === 'gossip'
|
|
93
|
-
? [
|
|
94
|
-
: [
|
|
90
|
+
? [GOSSIP.MAX_BYTES_PER_PERIOD, TRUST_VALUES.GOSSIP_FLOOD]
|
|
91
|
+
: [UNICAST.MAX_BYTES_PER_PERIOD, TRUST_VALUES.UNICAST_FLOOD];
|
|
95
92
|
// If under the limit, return true -> else apply penality and return undefined
|
|
96
93
|
if (this.bytesCounters[type][peerId] < maxByte) return true;
|
|
97
94
|
return this.adjustTrust(peerId, penality, `Message ${type} flood detected`);
|
package/core/config.mjs
CHANGED
|
@@ -145,6 +145,8 @@ export const DISCOVERY = {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export const UNICAST = { // MARKERS RANGE: 0-127
|
|
148
|
+
/** Maximum number of bytes per period | Default: 2_000_000 (2MB per period of 10 seconds) */
|
|
149
|
+
MAX_BYTES_PER_PERIOD: 2_000_000,
|
|
148
150
|
/** Maximum number of hops(relaying) for direct message | Default: 8
|
|
149
151
|
* - Default: 8, light: 6, super-light: 4, direct-only: 2 */
|
|
150
152
|
MAX_HOPS: 8,
|
|
@@ -172,6 +174,8 @@ export const UNICAST = { // MARKERS RANGE: 0-127
|
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
export const GOSSIP = { // MARKERS RANGE: 128-255
|
|
177
|
+
/** Maximum number of bytes per period | Default: 5_000_000 (5MB per period of 10 seconds) */
|
|
178
|
+
MAX_BYTES_PER_PERIOD: 5_000_000,
|
|
175
179
|
/** Time to consider a message as valid | Default: 10_000 (10 seconds) */
|
|
176
180
|
EXPIRATION: 10_000,
|
|
177
181
|
/** Time to keep messages in cache to avoid reprocessing | Default: 20_000 (20 seconds) */
|