Skip to content
Snippets Groups Projects
Commit 161c3899 authored by Éloïs's avatar Éloïs
Browse files

Merge branch 'feature/checkblock-ignore-issuer' into dev

parents 2db8c037 87f95696
No related branches found
No related tags found
1 merge request!1305Feature/checkblock ignore issuer
......@@ -23,6 +23,7 @@
- Remove ArchiveDAO, which is a LokiJS artifact @c-geek
- Add to an interface ServerDAO methods that could be used by external modules @c-geek
- StatsDAL => replaced by LevelDB indexes @c-geek
- add `--nocheck-issuer` option to `gen-*` commands @c-geek
### Fixes
......
......@@ -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",
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);
}
/**
......
......@@ -57,6 +57,7 @@ direct_webstart \
-c \
--nostdout \
--noshuffle \
--nocheck-issuer \
--socks-proxy \
--tor-proxy \
--reaching-clear-ep \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment