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
Branches
Tags
1 merge request!1305Feature/checkblock ignore issuer
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
- Remove ArchiveDAO, which is a LokiJS artifact @c-geek - Remove ArchiveDAO, which is a LokiJS artifact @c-geek
- Add to an interface ServerDAO methods that could be used by external modules @c-geek - Add to an interface ServerDAO methods that could be used by external modules @c-geek
- StatsDAL => replaced by LevelDB indexes @c-geek - StatsDAL => replaced by LevelDB indexes @c-geek
- add `--nocheck-issuer` option to `gen-*` commands @c-geek
### Fixes ### Fixes
......
...@@ -45,6 +45,7 @@ export class DuniterBlockchain { ...@@ -45,6 +45,7 @@ export class DuniterBlockchain {
static async checkBlock( static async checkBlock(
block: BlockDTO, block: BlockDTO,
withPoWAndSignature: boolean, withPoWAndSignature: boolean,
ignoreIssuer: boolean,
conf: ConfDTO, conf: ConfDTO,
dal: FileDAL dal: FileDAL
) { ) {
...@@ -78,7 +79,7 @@ export class DuniterBlockchain { ...@@ -78,7 +79,7 @@ export class DuniterBlockchain {
if (Indexer.rulePreviousIssuer(block, HEAD) === false) if (Indexer.rulePreviousIssuer(block, HEAD) === false)
throw Error("rulePreviousIssuer"); throw Error("rulePreviousIssuer");
// BR_G101 // BR_G101
if (Indexer.ruleIssuerIsMember(HEAD) === false) if (!ignoreIssuer && Indexer.ruleIssuerIsMember(HEAD) === false)
throw Error("ruleIssuerIsMember"); throw Error("ruleIssuerIsMember");
// BR_G54 // BR_G54
if (Indexer.ruleIssuersCount(block, HEAD) === false) if (Indexer.ruleIssuersCount(block, HEAD) === false)
...@@ -215,7 +216,7 @@ export class DuniterBlockchain { ...@@ -215,7 +216,7 @@ export class DuniterBlockchain {
}; };
const isMember = await dal.isMember(block.issuer); const isMember = await dal.isMember(block.issuer);
if (!isMember) { if (!ignoreIssuer && !isMember) {
if (block.number == 0) { if (block.number == 0) {
if (!matchesList(new RegExp("^" + block.issuer + ":"), block.joiners)) { if (!matchesList(new RegExp("^" + block.issuer + ":"), block.joiners)) {
throw Error("Block not signed by the root members"); throw Error("Block not signed by the root members");
......
...@@ -123,11 +123,13 @@ export class BlockchainContext { ...@@ -123,11 +123,13 @@ export class BlockchainContext {
async checkBlock( async checkBlock(
block: BlockDTO, block: BlockDTO,
withPoWAndSignature: boolean withPoWAndSignature: boolean,
ignoreIssuer: boolean
): Promise<any> { ): Promise<any> {
return DuniterBlockchain.checkBlock( return DuniterBlockchain.checkBlock(
block, block,
withPoWAndSignature, withPoWAndSignature,
ignoreIssuer,
this.conf, this.conf,
this.dal this.dal
); );
...@@ -205,7 +207,8 @@ export class BlockchainContext { ...@@ -205,7 +207,8 @@ export class BlockchainContext {
async checkAndAddBlock(block: BlockDTO, trim = true) { async checkAndAddBlock(block: BlockDTO, trim = true) {
const { index, HEAD } = await this.checkBlock( const { index, HEAD } = await this.checkBlock(
block, block,
constants.WITH_SIGNATURES_AND_POW constants.WITH_SIGNATURES_AND_POW,
false
); );
return await this.addBlock(block, index, HEAD, trim); return await this.addBlock(block, index, HEAD, trim);
} }
......
...@@ -591,6 +591,7 @@ export class GlobalIndexStream extends Duplex { ...@@ -591,6 +591,7 @@ export class GlobalIndexStream extends Duplex {
const { index, HEAD } = await DuniterBlockchain.checkBlock( const { index, HEAD } = await DuniterBlockchain.checkBlock(
dto, dto,
constants.WITH_SIGNATURES_AND_POW, constants.WITH_SIGNATURES_AND_POW,
false,
this.conf, this.conf,
this.dal this.dal
); );
......
...@@ -122,6 +122,10 @@ export const ProverDependency = { ...@@ -122,6 +122,10 @@ export const ProverDependency = {
desc: desc:
"With gen-* commands: the generated block is submitted to this node only.", "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>", value: "--submit-host <host>",
desc: desc:
...@@ -276,7 +280,11 @@ function generateAndSend( ...@@ -276,7 +280,11 @@ function generateAndSend(
const parsed = parsers.parseBlock.syncWrite( const parsed = parsers.parseBlock.syncWrite(
block.getRawSigned() block.getRawSigned()
); );
await server.BlockchainService.checkBlock(parsed, false); await server.BlockchainService.checkBlock(
parsed,
false,
program.nocheckIssuer
);
logger.info("Acceptable block"); logger.info("Acceptable block");
next(); next();
} catch (e) { } catch (e) {
......
...@@ -165,9 +165,9 @@ export class BlockchainService extends FIFOService { ...@@ -165,9 +165,9 @@ export class BlockchainService extends FIFOService {
return bb; return bb;
} }
checkBlock(block: any, withPoWAndSignature = true) { checkBlock(block: any, withPoWAndSignature = true, ignoreIssuer = false) {
const dto = BlockDTO.fromJSONObject(block); const dto = BlockDTO.fromJSONObject(block);
return this.mainContext.checkBlock(dto, withPoWAndSignature); return this.mainContext.checkBlock(dto, withPoWAndSignature, ignoreIssuer);
} }
/** /**
......
...@@ -57,6 +57,7 @@ direct_webstart \ ...@@ -57,6 +57,7 @@ direct_webstart \
-c \ -c \
--nostdout \ --nostdout \
--noshuffle \ --noshuffle \
--nocheck-issuer \
--socks-proxy \ --socks-proxy \
--tor-proxy \ --tor-proxy \
--reaching-clear-ep \ --reaching-clear-ep \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment