diff --git a/source/agora/network/Manager.d b/source/agora/network/Manager.d index 714322973bc..0c2964e9063 100644 --- a/source/agora/network/Manager.d +++ b/source/agora/network/Manager.d @@ -900,7 +900,8 @@ public class NetworkManager ***************************************************************************/ public void getMissingBlockSigs (Ledger ledger, - scope void delegate (BlockHeader) @safe acceptHeader) @safe nothrow + scope ulong delegate(BlockHeader) @safe extra_sigs, + scope void delegate(BlockHeader) @safe acceptHeader) @safe nothrow { import std.algorithm; import std.conv; @@ -939,9 +940,10 @@ public class NetworkManager { foreach (header; peer.getBlockHeaders(missing_heights)) { - auto sig_signed_validators = iota(enrolled_validators[header.height]).filter!(i => - header.validators[i] || header.preimages[i] is Hash.init).count(); - if (sig_signed_validators > signed_validators[header.height]) + auto potential_sig_count = iota(enrolled_validators[header.height]).filter!(i => + header.validators[i] || header.preimages[i] is Hash.init).count() + + extra_sigs(header); + if (potential_sig_count > signed_validators[header.height]) { try { diff --git a/source/agora/node/FullNode.d b/source/agora/node/FullNode.d index a0fe2ece691..e43f91f1c19 100644 --- a/source/agora/node/FullNode.d +++ b/source/agora/node/FullNode.d @@ -556,7 +556,7 @@ public class FullNode : API try { - this.network.getMissingBlockSigs(this.ledger, &this.acceptHeader); + this.network.getMissingBlockSigs(this.ledger, &this.extra_sigs, &this.acceptHeader); } catch (Exception e) { @@ -582,6 +582,27 @@ public class FullNode : API this.network.getUnknownTXs(this.ledger); } + /*************************************************************************** + + Count extra signatures that could be added to the provided header. + + For Validators this is overridden as it stores signatures and could add + them to the header if missing. + + Params: + header = the block header fetched from another node + + Returns: + The number of signatures that could be added to the given header, + FullNode does not store signatures so will return 0 + + ***************************************************************************/ + + protected ulong extra_sigs (BlockHeader header) @safe + { + return 0; + } + /*************************************************************************** Push the header to upstream servers. diff --git a/source/agora/node/Validator.d b/source/agora/node/Validator.d index 26763b05776..fed4c845b50 100644 --- a/source/agora/node/Validator.d +++ b/source/agora/node/Validator.d @@ -428,6 +428,25 @@ public class Validator : FullNode, API super.acceptHeader(header); } + /*************************************************************************** + + Count extra signatures that could be added to the provided header. + + Params: + header = the block header fetched from another node + + Returns: + The number of signatures that could be added to the given header + + ***************************************************************************/ + + protected override ulong extra_sigs (BlockHeader header) @safe + { + const currentCount = header.validators.setCount; + this.nominator.updateMultiSignature(header); + return header.validators.setCount - currentCount; + } + /*************************************************************************** Receive an SCP envelope.