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

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

[fix] #1132 Too many "Could not reach" errors

parent df535606
......@@ -150,6 +150,8 @@ export const CommonConstants = {
CANNOT_ROOT_BLOCK_NO_MEMBERS: { httpCode: 400, uerr: { ucode: 2018, message: "Wrong new block: cannot make a root block without members" }},
IDENTITY_WRONGLY_SIGNED: { httpCode: 400, uerr: { ucode: 2019, message: "Weird, the signature is wrong and in the database." }},
TOO_OLD_IDENTITY: { httpCode: 400, uerr: { ucode: 2020, message: "Identity has expired and cannot be written in the blockchain anymore." }},
NEWER_PEER_DOCUMENT_AVAILABLE: { httpCode: 409, uerr: { ucode: 2022, message: "A newer peer document is available" }},
PEER_DOCUMENT_ALREADY_KNOWN: { httpCode: 400, uerr: { ucode: 2023, message: "Peer document already known" }},
TX_INPUTS_OUTPUTS_NOT_EQUAL: { httpCode: 400, uerr: { ucode: 2024, message: "Transaction inputs sum must equal outputs sum" }},
TX_OUTPUT_SUM_NOT_EQUALS_PREV_DELTAS: { httpCode: 400, uerr: { ucode: 2025, message: "Transaction output base amount does not equal previous base deltas" }},
BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK: { httpCode: 400, uerr: { ucode: 2026, message: "Blockstamp does not match a block" }},
......
......@@ -58,8 +58,8 @@ module.exports = {
IDENTITY_WRONGLY_SIGNED: CommonConstants.ERRORS.IDENTITY_WRONGLY_SIGNED,
TOO_OLD_IDENTITY: CommonConstants.ERRORS.TOO_OLD_IDENTITY,
NO_IDTY_MATCHING_PUB_OR_UID: { httpCode: 404, uerr: { ucode: 2021, message: "No identity matching this pubkey or uid" }},
NEWER_PEER_DOCUMENT_AVAILABLE: { httpCode: 409, uerr: { ucode: 2022, message: "A newer peer document is available" }},
PEER_DOCUMENT_ALREADY_KNOWN: { httpCode: 400, uerr: { ucode: 2023, message: "Peer document already known" }},
NEWER_PEER_DOCUMENT_AVAILABLE: CommonConstants.ERRORS.NEWER_PEER_DOCUMENT_AVAILABLE,
PEER_DOCUMENT_ALREADY_KNOWN: CommonConstants.ERRORS.PEER_DOCUMENT_ALREADY_KNOWN,
TX_INPUTS_OUTPUTS_NOT_EQUAL: CommonConstants.ERRORS.TX_INPUTS_OUTPUTS_NOT_EQUAL,
TX_OUTPUT_SUM_NOT_EQUALS_PREV_DELTAS: CommonConstants.ERRORS.TX_OUTPUT_SUM_NOT_EQUALS_PREV_DELTAS,
BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK: CommonConstants.ERRORS.BLOCKSTAMP_DOES_NOT_MATCH_A_BLOCK,
......
......@@ -8,6 +8,7 @@ import {CertificationDTO} from "../dto/CertificationDTO"
import {MembershipDTO} from "../dto/MembershipDTO"
import {TransactionDTO} from "../dto/TransactionDTO"
import {PeerDTO} from "../dto/PeerDTO"
import {CommonConstants} from "../common-libs/constants"
const request = require('request');
const constants = require('../../lib/constants');
......@@ -111,13 +112,29 @@ export class Multicaster extends stream.Transform {
},
getDocID: (doc:PeerDTO) => doc.keyID() + '#' + doc.blockNumber(),
withIsolation: WITH_ISOLATION,
onError: (resJSON:{ peer:{ block:string, endpoints:string[] }}, peering:any, to:any) => {
const sentPeer = PeerDTO.fromJSONObject(peering)
if (PeerDTO.blockNumber(resJSON.peer.block) > sentPeer.blockNumber()) {
this.push({ outdated: true, peer: resJSON.peer });
logger.warn('Outdated peer document (%s) sent to %s', sentPeer.keyID() + '#' + sentPeer.blockNumber(), to);
onError: (resJSON:{
peer: {
block:string,
endpoints:string[]
},
ucode?:number,
message?:string
}, peering:any, to:any) => {
if (resJSON.ucode !== undefined && resJSON.ucode !== CommonConstants.ERRORS.NEWER_PEER_DOCUMENT_AVAILABLE.uerr.ucode) {
if (resJSON.ucode == CommonConstants.ERRORS.DOCUMENT_BEING_TREATED.uerr.ucode || resJSON.ucode == constants.ERRORS.PEER_DOCUMENT_ALREADY_KNOWN.uerr.ucode) {
return Promise.resolve()
} else {
throw Error(resJSON.message)
}
} else {
// Handle possibly outdated peering document
const sentPeer = PeerDTO.fromJSONObject(peering)
if (PeerDTO.blockNumber(resJSON.peer.block) > sentPeer.blockNumber()) {
this.push({ outdated: true, peer: resJSON.peer });
logger.warn('Outdated peer document (%s) sent to %s', sentPeer.keyID() + '#' + sentPeer.blockNumber(), to);
}
return Promise.resolve()
}
return Promise.resolve();
}
})(doc, peers)
}
......
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