Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: cloudboy on August 20, 2014, 04:31:41 AM



Title: Lifecycle of a Message
Post by: cloudboy on August 20, 2014, 04:31:41 AM
I understand that messages are handled by ThreadMessageHandler in net.cpp, and are received/sent/processed in main.cpp.

My questions are:
  • If an unknown message is received (it will hit the final else statement in ProcessMessage() and be ignored) will it still be propagated to other nodes?
  • Is pnode->PushMessage() enough to broadcast a message? From what I understand, it adds the message to the queue of outgoing messages, which are then gathered by    SendMessages() and sent.
  • Is it possible to assign an expiration date to an individual message? So all nodes know to stop propagating it at that time?
  • How can you reject an incoming message and make sure it doesn't get relayed or processed?

Thanks


Title: Re: Lifecycle of a Message
Post by: theymos on August 20, 2014, 06:50:37 PM
Quote
If an unknown message is received (it will hit the final else statement in ProcessMessage() and be ignored) will it still be propagated to other nodes?

No.

Quote
Is pnode->PushMessage() enough to broadcast a message? From what I understand, it adds the message to the queue of outgoing messages, which are then gathered by    SendMessages() and sent.

PushMessage sends a message to a peer. Only certain message types are then broadcast to the rest of the network.

Quote
Is it possible to assign an expiration date to an individual message? So all nodes know to stop propagating it at that time?

No, but that's not necessary. Nodes don't propagate duplicate information, so block/tx/addr broadcasts reach every network node in a matter of minutes and then stop propagating.

Quote
How can you reject an incoming message and make sure it doesn't get relayed or processed?

Just ignore it when you receive it. ProcessMessage would probably be a good place to put additional logic of this sort.