diff --git a/app/modules/ws2p/lib/WS2PCluster.ts b/app/modules/ws2p/lib/WS2PCluster.ts index 5543a640bb62425a8da21202ff419a30355418ac..d607e9c2f5f5998d5140e32e6f7e55ee53784f76 100644 --- a/app/modules/ws2p/lib/WS2PCluster.ts +++ b/app/modules/ws2p/lib/WS2PCluster.ts @@ -116,8 +116,8 @@ export class WS2PCluster { // More recent? if (!this.headsCache[fullId] || parseInt(this.headsCache[fullId].blockstamp) < parseInt(blockstamp)) { // Check that issuer is a member and that the block exists - const memberKey = await this.isMemberKey(pub) - if (memberKey) { + const isAllowed = pub === this.server.conf.pair.pub || this.isConnectedKey(pub) || (await this.isMemberKey(pub)) + if (isAllowed) { const exists = await this.existsBlock(blockstamp) if (exists) { this.headsCache[fullId] = { blockstamp, message, sig } @@ -152,8 +152,8 @@ export class WS2PCluster { // More recent? if (!this.headsCache[fullId] || parseInt(this.headsCache[fullId].blockstamp) < parseInt(blockstamp)) { // Check that issuer is a member and that the block exists - const memberKey = await this.isMemberKey(pub) - if (memberKey) { + const isAllowed = pub === this.server.conf.pair.pub || this.isConnectedKey(pub) || (await this.isMemberKey(pub)) + if (isAllowed) { const exists = await this.existsBlock(blockstamp) if (exists) { this.headsCache[fullId] = { blockstamp, message, sig } @@ -195,11 +195,17 @@ export class WS2PCluster { // Do we have this block in the DB? isMember = !!(await this.server.dal.isMember(pub)) } - // Update the last time it was checked - this.memberkeysCache[pub] = Date.now() + if (isMember) { + // Update the last time it was checked + this.memberkeysCache[pub] = Date.now() + } return isMember } + private isConnectedKey(pub:string) { + return this.getConnectedPubkeys().indexOf(pub) !== -1 + } + private async existsBlock(blockstamp:string) { let exists = false if (this.blockstampsCache[blockstamp]) {