Skip to content
Snippets Groups Projects
Commit db03e279 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[feat] generator: add `--nocheck-issuer` option

parent 2db8c037
No related branches found
No related tags found
1 merge request!1305Feature/checkblock ignore issuer
......@@ -45,6 +45,7 @@ export class DuniterBlockchain {
static async checkBlock(
block: BlockDTO,
withPoWAndSignature: boolean,
ignoreIssuer: boolean,
conf: ConfDTO,
dal: FileDAL
) {
......@@ -78,7 +79,7 @@ export class DuniterBlockchain {
if (Indexer.rulePreviousIssuer(block, HEAD) === false)
throw Error("rulePreviousIssuer");
// BR_G101
if (Indexer.ruleIssuerIsMember(HEAD) === false)
if (!ignoreIssuer && Indexer.ruleIssuerIsMember(HEAD) === false)
throw Error("ruleIssuerIsMember");
// BR_G54
if (Indexer.ruleIssuersCount(block, HEAD) === false)
......@@ -215,7 +216,7 @@ export class DuniterBlockchain {
};
const isMember = await dal.isMember(block.issuer);
if (!isMember) {
if (!ignoreIssuer && !isMember) {
if (block.number == 0) {
if (!matchesList(new RegExp("^" + block.issuer + ":"), block.joiners)) {
throw Error("Block not signed by the root members");
......
......@@ -123,11 +123,13 @@ export class BlockchainContext {
async checkBlock(
block: BlockDTO,
withPoWAndSignature: boolean
withPoWAndSignature: boolean,
ignoreIssuer: boolean
): Promise<any> {
return DuniterBlockchain.checkBlock(
block,
withPoWAndSignature,
ignoreIssuer,
this.conf,
this.dal
);
......@@ -205,7 +207,8 @@ export class BlockchainContext {
async checkAndAddBlock(block: BlockDTO, trim = true) {
const { index, HEAD } = await this.checkBlock(
block,
constants.WITH_SIGNATURES_AND_POW
constants.WITH_SIGNATURES_AND_POW,
false
);
return await this.addBlock(block, index, HEAD, trim);
}
......
......@@ -591,6 +591,7 @@ export class GlobalIndexStream extends Duplex {
const { index, HEAD } = await DuniterBlockchain.checkBlock(
dto,
constants.WITH_SIGNATURES_AND_POW,
false,
this.conf,
this.dal
);
......
......@@ -122,6 +122,10 @@ export const ProverDependency = {
desc:
"With gen-* commands: the generated block is submitted to this node only.",
},
{
value: "--nocheck-issuer",
  • Éloïs @librelois ·
    Owner

    @c-geek , Duniter intègre désormais un script d'autocompéltion dans release/extra/completion/duniter_completion.bash.

    Il faut désormais mettre a jours ce script a chaque modification des commandes cli :)

  • Author Owner

    Yes, c'est pushé !

  • Please register or sign in to reply
desc: "With gen-* commands: ignore issuer rule.",
},
{
value: "--submit-host <host>",
desc:
......@@ -276,7 +280,11 @@ function generateAndSend(
const parsed = parsers.parseBlock.syncWrite(
block.getRawSigned()
);
await server.BlockchainService.checkBlock(parsed, false);
await server.BlockchainService.checkBlock(
parsed,
false,
program.nocheckIssuer
);
logger.info("Acceptable block");
next();
} catch (e) {
......
......@@ -165,9 +165,9 @@ export class BlockchainService extends FIFOService {
return bb;
}
checkBlock(block: any, withPoWAndSignature = true) {
checkBlock(block: any, withPoWAndSignature = true, ignoreIssuer = false) {
const dto = BlockDTO.fromJSONObject(block);
return this.mainContext.checkBlock(dto, withPoWAndSignature);
return this.mainContext.checkBlock(dto, withPoWAndSignature, ignoreIssuer);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment