protected function getKeyUpdates(MerkleTree $tree) : array
{
$newNodes = [];
foreach ($this->getChannelUpdates($tree->getRoot()) as $new) {
$newNode = new Node($new['data']);
$tree = $tree->getExpandedTree($newNode);
// Verify that we've calculated the same Merkle root for each new leaf:
if (\hash_equals($new['root'], $tree->getRoot())) {
// Attempt to store the update (and create/revoke copies of the public keys):
if ($this->storeUpdate($new)) {
$newNodes[] = $newNode;
}
}
}
if (\count($newNodes) > 0) {
$this->notifyPeersOfNewUpdate();
}
return $newNodes;
}