|
|
@ -44,8 +44,19 @@ $debug = [ |
|
|
|
'insert' => 0, |
|
|
|
'insert' => 0, |
|
|
|
'update' => 0, |
|
|
|
'update' => 0, |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'coordinate' => [ |
|
|
|
|
|
|
|
'total' => [ |
|
|
|
|
|
|
|
'insert' => 0, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'route' => [ |
|
|
|
|
|
|
|
'total' => [ |
|
|
|
|
|
|
|
'insert' => 0, |
|
|
|
|
|
|
|
'delete' => 0, |
|
|
|
] |
|
|
|
] |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
] |
|
|
|
] |
|
|
|
] |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
@ -82,7 +93,7 @@ if ($connectedPeers = Yggverse\Yggdrasilctl\Yggdrasil::getPeers()) { |
|
|
|
$debug['yggdrasil']['peer']['total']['insert']++; |
|
|
|
$debug['yggdrasil']['peer']['total']['insert']++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Init peer data |
|
|
|
// Init peer remote |
|
|
|
if ($connectedPeerRemoteUrl = Yggverse\Parser\Url::parse($connectedPeerInfo->remote)) { |
|
|
|
if ($connectedPeerRemoteUrl = Yggverse\Parser\Url::parse($connectedPeerInfo->remote)) { |
|
|
|
|
|
|
|
|
|
|
|
if ($dbPeerRemote = $db->findPeerRemote($dbPeerId, |
|
|
|
if ($dbPeerRemote = $db->findPeerRemote($dbPeerId, |
|
|
@ -122,6 +133,38 @@ if ($connectedPeers = Yggverse\Yggdrasilctl\Yggdrasil::getPeers()) { |
|
|
|
|
|
|
|
|
|
|
|
$debug['yggdrasil']['peer']['remote']['total']['insert']++; |
|
|
|
$debug['yggdrasil']['peer']['remote']['total']['insert']++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init peer coordinate |
|
|
|
|
|
|
|
if ($dbPeerCoordinate = $db->getLastCoordinate($dbPeerId)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$peerCoordinateId = $dbPeerCoordinate->peerCoordinateId; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$peerCoordinateId = $db->addPeerCoordinate($dbPeerId, $connectedPeerInfo->port, time()); |
|
|
|
|
|
|
|
$debug['yggdrasil']['peer']['coordinate']['total']['insert']++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init peer coordinate route |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$localPeerCoordinateRoute = []; |
|
|
|
|
|
|
|
foreach ($db->getPeerCoordinateRoute($peerCoordinateId) as $dbPeerCoordinateRoute) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$localPeerCoordinateRoute[$dbPeerCoordinateRoute->level] = $dbPeerCoordinateRoute->port; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Compare remote and local routes to prevent write operations |
|
|
|
|
|
|
|
if ($localPeerCoordinateRoute !== $connectedPeerInfo->coords) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$debug['yggdrasil']['peer']['coordinate']['route']['total']['delete'] += |
|
|
|
|
|
|
|
$db->flushPeerCoordinateRoute($peerCoordinateId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($connectedPeerInfo->coords as $level => $port) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$debug['yggdrasil']['peer']['coordinate']['route']['total']['insert'] += |
|
|
|
|
|
|
|
$db->addPeerCoordinateRoute($peerCoordinateId, $level, $port); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$debug['yggdrasil']['peer']['total']['online']++; |
|
|
|
$debug['yggdrasil']['peer']['total']['online']++; |
|
|
|