@@ -529,22 +529,19 @@ class StateGossipAgent extends PeeringAgentBase {
529529
530530 if ( stateHash !== this . getRemoteState ( sender , agentId ) ) {
531531 if ( await stateObj . validate ( new Map ( ) ) ) {
532-
533-
534- this . setRemoteState ( sender , agentId , stateHash , stateObj ) ;
535- this . cachePreviousState ( agentId , stateHash , stateObj ) ;
536532
537533 let receivedOldState = false ;
538534
539535 try {
540536 receivedOldState = ! ( await this . notifyAgentOfStateArrival ( sender , agentId , stateHash , stateObj ) ) ;
537+ this . setRemoteState ( sender , agentId , stateHash , stateObj ) ;
538+ this . cachePreviousState ( agentId , stateHash , stateObj ) ;
539+ StateGossipAgent . controlLog . trace ( 'Received state for ' + agentId + ': (' + stateHash + '-' + ( receivedOldState ? 'old' : 'new' ) + ')' ) ;
541540 } catch ( e ) {
542541 // maybe cache erroneous states so we don't process them over and over?
543542 StateGossipAgent . controlLog . warning ( 'Received erroneous state from ' + sender + ' for ' + agentId , e ) ;
544543 }
545544
546- StateGossipAgent . controlLog . trace ( 'Received state for ' + agentId + ': (' + stateHash + '-' + ( receivedOldState ? 'old' : 'new' ) + ')' ) ;
547-
548545 if ( receivedOldState && this . localState . get ( agentId ) !== stateHash && this . localStateObjects . get ( agentId ) !== undefined ) {
549546 this . peerMessageLog . trace ( 'Received old state for ' + agentId + ' from ' + sender + ', sending our own state over there.' ) ;
550547 this . sendStateObject ( sender , agentId ) ;
@@ -643,7 +640,7 @@ class StateGossipAgent extends PeeringAgentBase {
643640
644641 this . sentStateCache . set ( lastSentKey , { timestamp : newTimestamp , stateHash : stateLiteral . hash , repeats : newRepeats } ) ;
645642 } else {
646- this . controlLog . debug ( 'Sending state failed!' ) ;
643+ this . controlLog . debug ( 'Sending state failed for ' + agentId + ' !') ;
647644 }
648645 } else {
649646 this . controlLog . warning ( 'not gossiping: repeats = ' + lastSent ?. repeats + ' for agent ' + agentId ) ;
0 commit comments