Avoid processing own messages (2x)#1010
Conversation
OnInvMessageReceived(PH):
printingPayloadHashes(PH)-1978586386-1565297075: 0x9090abff17aa3b88d2fd35d51f514e68395b30657d6590acc91fa08d9ace5c04
printingHashesFiltered(PH)-1978586386-1565297075: 0x9090abff17aa3b88d2fd35d51f514e68395b30657d6590acc91fa08d9ace5c04
TM-IHP: Consensus I AM...
OnInvMessageReceived (PH): hashes=0 sentByMe=False
OnNewTasks(TM)-BGN-842930168-1565297075
OnNewTasks(TM)-BKS-842930168-1565297075:
NewTaskHashesOnTM(TM)-842930168-1565297075: 0x9090abff17aa3b88d2fd35d51f514e68395b30657d6590acc91fa08d9ace5c04
OnNewTasks(TM)-AKS-842930168-1565297075-count: 0
OnNewTasks(TM)-AGT-842930168-1565297075-count: 0
OnInvMessageReceived (PH): hashes=1 sentByMe=False
OnInvMessageReceived(PH):
printingPayloadHashes(PH)-1053130781-1565297075: 0x75bb0c087793e08aa85258851cc70f722455801888ffbf418ba94a6af2515bb7
printingHashesFiltered(PH)-1053130781-1565297075: 0x75bb0c087793e08aa85258851cc70f722455801888ffbf418ba94a6af2515bb7
TM-IHP: Consensus I AM...
OnNewTasks(TM)-BGN-1303385166-1565297075
OnNewTasks(TM)-BKS-1303385166-1565297075:
NewTaskHashesOnTM(TM)-1303385166-1565297075: 0x75bb0c087793e08aa85258851cc70f722455801888ffbf418ba94a6af2515bb7
OnNewTasks(TM)-AKS-1303385166-1565297075-count: 0
OnNewTasks(TM)-AGT-1303385166-1565297075-count: 0
OnInvMessageReceived (PH): hashes=0 sentByMe=False
OnInvMessageReceived (PH): hashes=1 sentByMe=True
OnInvMessageReceived (PH): hashes=1 sentByMe=True
OnInvMessageReceived (PH): hashes=0 sentByMe=True
OnInvMessageReceived (PH): hashes=0 sentByMe=True
OnInvMessageReceived (PH): hashes=1 sentByMe=False
OnInvMessageReceived (PH): hashes=1 sentByMe=False
OnInvMessageReceived(PH):
printingPayloadHashes(PH)-1357786701-1565297094: 0x6254eacb6733db25e01ef599b1b5cbc03745337e4000f29b49385dc2deff2b30
printingHashesFiltered(PH)-1357786701-1565297094: 0x6254eacb6733db25e01ef599b1b5cbc03745337e4000f29b49385dc2deff2b30Check how many |
|
@erikzhang, please double check, just to be sure that nothing wrong is being done.
private void OnGetDataMessageReceived(InvPayload payload)
{
UInt256[] hashes = payload.Hashes.Where(p => sentHashes.Add(p)).ToArray();
(....)
Context.Parent.Tell(Message.Create("consensus", inventory));The |
|
maybe we can add the sentHashes into knownHashes |
|
Could be another option, @shargon, sounds good as well but makes us duplicate the local storage in the local memory. |
|
This will surely save many |
|
@yongjiema, I am close to accept...aehauheuaea |
Co-Authored-By: Shargon <shargon@gmail.com>
|
I will test the behavior, give me one day |
| private void OnInvMessageReceived(InvPayload payload) | ||
| { | ||
| UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p)).ToArray(); | ||
| UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p) && !sentHashes.Contains(p)).ToArray(); |
There was a problem hiding this comment.
This will naturally add to knownHashes, as Add will run before sentHashes is verified... interesting.
If this is not intended, we need to reverse this && here...
There was a problem hiding this comment.
The intend is to verify this:
bool sentByMe = payload.Hashes.Any(p => sentHashes.Contains(p));
if (hashes.Length == 0 || sentByMe) return;Check if there is Any of this hashes in the SentHashes.
Is this the same as it is? Shargon suggested this embed in a single line.
There was a problem hiding this comment.
And where is p => knownHashes.Add(p) part? hahahah
Replication of #1009 on master2x.
It can be seen as a minor bug fix or an improvement. Thus, fell free to close.
But this may help us in the hunt for avoiding duplicated tasks processing and probably, consequently, solving P2P minor problems that are bordering our nodes.