@@ -3465,47 +3465,51 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
34653465
34663466 else if (strCommand == " xbridge" )
34673467 {
3468- std::vector<unsigned char > raw;
3469- vRecv >> raw;
3470-
3471- uint256 hash = Hash (raw.begin (), raw.end ());
3472- if (!pfrom->setKnown .count (hash))
3468+ static bool isEnabled = XBridgeApp::isEnabled ();
3469+ if (isEnabled)
34733470 {
3474- pfrom->setKnown .insert (hash);
3471+ std::vector<unsigned char > raw;
3472+ vRecv >> raw;
34753473
3476- // Relay
3474+ uint256 hash = Hash (raw.begin (), raw.end ());
3475+ if (!pfrom->setKnown .count (hash))
34773476 {
3478- LOCK (cs_vNodes);
3479- for (CNode * pnode : vNodes)
3477+ pfrom->setKnown .insert (hash);
3478+
3479+ // Relay
34803480 {
3481- if (pnode->setKnown .insert (hash).second )
3481+ LOCK (cs_vNodes);
3482+ for (CNode * pnode : vNodes)
34823483 {
3483- pnode->PushMessage (" xbridge" , raw);
3484+ if (pnode->setKnown .insert (hash).second )
3485+ {
3486+ pnode->PushMessage (" xbridge" , raw);
3487+ }
34843488 }
34853489 }
3486- }
34873490
3488- if (raw.size () > 20 + sizeof (time_t ))
3489- {
3490- static std::vector<unsigned char > zero (20 , 0 );
3491- std::vector<unsigned char > addr (raw.begin (), raw.begin ()+20 );
3492- // remove addr from raw
3493- raw.erase (raw.begin (), raw.begin ()+20 );
3494- // remove timestamp from raw
3495- raw.erase (raw.begin (), raw.begin ()+sizeof (uint64_t ));
3491+ if (raw.size () > 20 + sizeof (time_t ))
3492+ {
3493+ static std::vector<unsigned char > zero (20 , 0 );
3494+ std::vector<unsigned char > addr (raw.begin (), raw.begin ()+20 );
3495+ // remove addr from raw
3496+ raw.erase (raw.begin (), raw.begin ()+20 );
3497+ // remove timestamp from raw
3498+ raw.erase (raw.begin (), raw.begin ()+sizeof (uint64_t ));
34963499
3497- XBridgeApp & app = XBridgeApp::instance ();
3500+ XBridgeApp & app = XBridgeApp::instance ();
34983501
3499- if (addr != zero)
3500- {
3501- app.onMessageReceived (addr, raw);
3502- }
3503- else
3504- {
3505- app.onBroadcastReceived (raw);
3502+ if (addr != zero)
3503+ {
3504+ app.onMessageReceived (addr, raw);
3505+ }
3506+ else
3507+ {
3508+ app.onBroadcastReceived (raw);
3509+ }
35063510 }
35073511 }
3508- }
3512+ } // if (isEnabled)
35093513 }
35103514
35113515 // messages
0 commit comments