local broadcast
This commit is contained in:
@@ -30,5 +30,6 @@ $_config['allowed_hosts']=array("127.0.0.1");
|
|||||||
$_config['sanity_interval']=900;
|
$_config['sanity_interval']=900;
|
||||||
// accept the setting of new hostnames / should be used only if you want to change the hostname
|
// accept the setting of new hostnames / should be used only if you want to change the hostname
|
||||||
$_config['allow_hostname_change']=false;
|
$_config['allow_hostname_change']=false;
|
||||||
|
// rebroadcast local transactions on each sanity
|
||||||
|
$_config['sanity_rebroadcast_locals']=true;
|
||||||
?>
|
?>
|
||||||
|
|||||||
13
sanity.php
13
sanity.php
@@ -160,6 +160,8 @@ if($total_peers==0&&$_config['testnet']==false){
|
|||||||
foreach($f as $peer){
|
foreach($f as $peer){
|
||||||
//peer with all until max_peers, this will ask them to send a peering request to our peer.php where we add their peer to the db.
|
//peer with all until max_peers, this will ask them to send a peering request to our peer.php where we add their peer to the db.
|
||||||
$peer=trim($peer);
|
$peer=trim($peer);
|
||||||
|
$bad_peers=array("127.0.0.1","localhost");
|
||||||
|
if(str_replace($bad_peers,"",$peer)!=$peer) continue;
|
||||||
$peer = filter_var($peer, FILTER_SANITIZE_URL);
|
$peer = filter_var($peer, FILTER_SANITIZE_URL);
|
||||||
if (!filter_var($peer, FILTER_VALIDATE_URL)) continue;
|
if (!filter_var($peer, FILTER_VALIDATE_URL)) continue;
|
||||||
// store the hostname as md5 hash, for easier checking
|
// store the hostname as md5 hash, for easier checking
|
||||||
@@ -378,6 +380,17 @@ if($current['height']<$largest_height&&$largest_height>1){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//rebroadcasting local transactions
|
||||||
|
if($_config['sanity_rebroadcast_locals']==true){
|
||||||
|
$r=$db->run("SELECT id FROM mempool WHERE height>=:current and peer='local' order by `height` asc LIMIT 20",array(":current"=>$current['height']));
|
||||||
|
foreach($r as $x){
|
||||||
|
$x['id']=san($x['id']);
|
||||||
|
system("php propagate.php transaction $x[id] > /dev/null 2>&1 &");
|
||||||
|
$db->run("UPDATE mempool SET height=:current WHERE id=:id",array(":id"=>$x['id'], ":current"=>$current['height']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//rebroadcasting transactions
|
//rebroadcasting transactions
|
||||||
$forgotten=$current['height']-$_config['sanity_rebroadcast_height'];
|
$forgotten=$current['height']-$_config['sanity_rebroadcast_height'];
|
||||||
$r=$db->run("SELECT id FROM mempool WHERE height<:forgotten ORDER by val DESC LIMIT 10",array(":forgotten"=>$forgotten));
|
$r=$db->run("SELECT id FROM mempool WHERE height<:forgotten ORDER by val DESC LIMIT 10",array(":forgotten"=>$forgotten));
|
||||||
|
|||||||
Reference in New Issue
Block a user