passive peering

This commit is contained in:
admin@arionum.com
2018-10-25 21:11:24 +03:00
parent 3251f98ebf
commit 88f50fcae1
8 changed files with 27 additions and 15 deletions

View File

@@ -301,7 +301,15 @@ if ($total_peers == 0 && $_config['testnet'] == false) {
continue;
}
$peered[$pid] = 1;
$res = peer_post($peer."/peer.php?q=peer", ["hostname" => $_config['hostname'], "repeer" => 1]);
if($_config['passive_peering'] == true){
// does not peer, just add it to DB in passive mode
$db->run("INSERT into peers set hostname=:hostname, ping=0, reserve=0,ip=:ip",[":hostname"=>$peer, ":ip"=>md5($peer)]);
$res=true;
} else {
// forces the other node to peer with us.
$res = peer_post($peer."/peer.php?q=peer", ["hostname" => $_config['hostname'], "repeer" => 1]);
}
if ($res !== false) {
$i++;
echo "Peering OK - $peer\n";
@@ -328,7 +336,7 @@ foreach ($r as $x) {
_log("Contacting peer $x[hostname]");
$url = $x['hostname']."/peer.php?q=";
// get their peers list
if ($_config['get_more_peers']==true) {
if ($_config['get_more_peers']==true && $_config['passive_peering']!=true) {
$data = peer_post($url."getPeers", [], 5);
if ($data === false) {
_log("Peer $x[hostname] unresponsive");