@@ -380,6 +380,14 @@ handle_broadcast(false, _MessageId, _Message, Mod, _Round, Root, From, State) ->
380380 State1 = add_lazy (From , Root , State ),
381381 _ = send ({prune , Root , myself ()}, Mod , From ),
382382 State1 ;
383+ % % The next clause is designed to allow the callback to override the message id
384+ % % after the merge, suppose node A eager pushed a change to node B, node B would then lazy
385+ % % push it to node C, at this point the message id being sent to C is the one that originated
386+ % % from A. Concurrently B takes an update that subsumes the previous one, now node C receives the
387+ % % lazy push and hasn't seen this message and asks B to graft it, if C now sends the message id
388+ % % that it got from A, node B will not answer the graft since it is deemed stale.
389+ % % With this extra clause the callback is able to return a new message id that resulted from
390+ % % the merge and have that be propagated.
383391handle_broadcast ({true , MessageId }, _OldMessageId , Message , Mod , Round , Root , From , State ) ->
384392 handle_broadcast (true , MessageId , Message , Mod , Round , Root , From , State );
385393handle_broadcast (true , MessageId , Message , Mod , Round , Root , From , State ) -> % % valid msg
@@ -467,8 +475,6 @@ send_lazy(Peer, Messages) ->
467475 {MessageId , Mod , Round , Root } <- ordsets :to_list (Messages )].
468476
469477send_lazy (MessageId , Mod , Round , Root , Peer ) ->
470- % plumtree_util:log(debug, "sending lazy push ~p",
471- % [{i_have, MessageId, Mod, Round, Root, myself()}]),
472478 send ({i_have , MessageId , Mod , Round , Root , myself ()}, Mod , Peer ).
473479
474480maybe_exchange (State ) ->
0 commit comments