diff --git a/include/config.inc.php b/include/config.inc.php index 11fdc42..67a1f71 100755 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -30,5 +30,6 @@ $_config['allowed_hosts']=array("127.0.0.1"); $_config['sanity_interval']=900; // accept the setting of new hostnames / should be used only if you want to change the hostname $_config['allow_hostname_change']=false; - +// rebroadcast local transactions on each sanity +$_config['sanity_rebroadcast_locals']=true; ?> diff --git a/sanity.php b/sanity.php index 61020e2..eaaa559 100755 --- a/sanity.php +++ b/sanity.php @@ -160,6 +160,8 @@ if($total_peers==0&&$_config['testnet']==false){ 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=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); if (!filter_var($peer, FILTER_VALIDATE_URL)) continue; // 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 $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));