Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit ea0c43a5 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] Make Duniter services start more quickly

parent 0826538e
......@@ -512,14 +512,25 @@ export class WS2PCluster {
return all
}
async startCrawling() {
async startCrawling(waitConnection = false) {
// For blocks
if (this.syncBlockInterval)
clearInterval(this.syncBlockInterval);
this.syncBlockInterval = setInterval(() => this.pullBlocks(), 1000 * WS2PConstants.BLOCK_PULLING_INTERVAL)
this.syncBlockInterval = setInterval(() => this.pullBlocks(), 1000 * WS2PConstants.BLOCK_PULLING_INTERVAL);
// Pull blocks right on start
await this.connectToWS2Peers()
await this.pullBlocks()
const init = async () => {
try {
await this.connectToWS2Peers()
await this.pullBlocks()
} catch (e) {
this.server.logger.error(e)
}
}
if (waitConnection) {
await init()
} else {
init()
}
// For docpool
if (this.syncDocpoolInterval)
clearInterval(this.syncDocpoolInterval);
......
......@@ -115,8 +115,8 @@ describe("WS2P client limitations", function() {
'WS2P 11111111 127.0.0.1 ' + portWS1
])
await s2.writePeer(p1)
await (s1._server.ws2pCluster as WS2PCluster).startCrawling()
await (s2._server.ws2pCluster as WS2PCluster).startCrawling()
await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
await (s2._server.ws2pCluster as WS2PCluster).startCrawling(true)
await s1.expect('/network/ws2p/info', (res:any) => {
assert.equal(res.peers.level1, 0)
assert.equal(res.peers.level2, 1)
......
......@@ -93,7 +93,7 @@ describe("WS2P cluster", function() {
])
await s2.writePeer(p1)
WS2PCluster.plugOn(s2._server);
await (s2._server.ws2pCluster as WS2PCluster).startCrawling()
await (s2._server.ws2pCluster as WS2PCluster).startCrawling(true)
await s1.expect('/network/ws2p/info', (res:any) => {
assert.equal(res.peers.level1, 0)
assert.equal(res.peers.level2, 1)
......@@ -105,7 +105,7 @@ describe("WS2P cluster", function() {
})
it('should not start another connection if peer is already connected', async () => {
await (s1._server.ws2pCluster as WS2PCluster).startCrawling()
await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
await s1.expect('/network/ws2p/info', (res:any) => {
assert.equal(res.peers.level1, 0) // <- Does not increase!
assert.equal(res.peers.level2, 1)
......
......@@ -70,8 +70,8 @@ describe("WS2P heads propagation", function() {
'WS2P 11111111 127.0.0.1 ' + portWS1
])
await s2.writePeer(p1)
await (s1._server.ws2pCluster as WS2PCluster).startCrawling()
await (s2._server.ws2pCluster as WS2PCluster).startCrawling()
await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
await (s2._server.ws2pCluster as WS2PCluster).startCrawling(true)
await s1.expect('/network/ws2p/info', (res:any) => {
assert.equal(res.peers.level1, 0)
assert.equal(res.peers.level2, 1)
......
......@@ -84,7 +84,7 @@ describe("WS2P network", function() {
])
await s2.writePeer(p1)
WS2PCluster.plugOn(s2._server);
await (s2._server.ws2pCluster as WS2PCluster).startCrawling()
await (s2._server.ws2pCluster as WS2PCluster).startCrawling(true)
// const network = await simpleWS2PNetwork(s1, s2)
// wss = network.wss
// cluster2 = network.cluster2
......
......@@ -118,9 +118,9 @@ describe("WS2P server limitations", function() {
'WS2P 11111111 127.0.0.1 ' + portWS1
])
await s2.writePeer(p1)
await (s1._server.ws2pCluster as WS2PCluster).startCrawling()
await (s2._server.ws2pCluster as WS2PCluster).startCrawling()
await (s3._server.ws2pCluster as WS2PCluster).startCrawling()
await (s1._server.ws2pCluster as WS2PCluster).startCrawling(true)
await (s2._server.ws2pCluster as WS2PCluster).startCrawling(true)
await (s3._server.ws2pCluster as WS2PCluster).startCrawling(true)
await s1.expect('/network/ws2p/info', (res:any) => {
assert.equal(res.peers.level1, 0)
assert.equal(res.peers.level2, 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment