Skip to content

Commit

Permalink
update default nodes and timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
deemru committed Aug 15, 2024
1 parent 93483ce commit 6f3432b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/WavesKit.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct( $chainId = 'W', $logFunction = null, $keyCaching =
if( !isset( $this->curlTimeout ) )
{
if( !defined( 'WK_CURL_TIMEOUT' ) )
define( 'WK_CURL_TIMEOUT', 5 );
define( 'WK_CURL_TIMEOUT', 15 );

$this->curlTimeout = WK_CURL_TIMEOUT;
}
Expand Down Expand Up @@ -667,6 +667,7 @@ public function setNodeAddress( $nodeAddress, $cacheLifetime = 0.5, $backupNodes
if( isset( $backupNodes ) )
$hosts = array_merge( $hosts, $backupNodes );
$this->fetcher = Fetcher::hosts( $hosts )->setTimeoutCache( $cacheLifetime );
$this->fetcher->setTimeoutConnect( $this->curlTimeout )->setTimeoutExec( $this->curlTimeout )->setOptions( $this->curlOptions );
if( count( $hosts ) > 1 && defined( 'WK_CURL_SETBESTONERROR' ) )
$this->setBestOnError = true;
}
Expand All @@ -683,23 +684,30 @@ public function getNodeAddress()

private function setDefaultNode()
{
if( $this->getNodeAddress() === false )
if( !isset( $this->fetcher ) )
{
switch( $this->chainId )
{
case 'W':
$this->setNodeAddress( 'https://nodes.wavesplatform.com' );
$this->setNodeAddress( [
'https://nodes.wavesplatform.com',
'https://nodes.wavesnodes.com',
'https://nodes.wx.network',
'https://nodes.wavesexplorer.com',
] );
break;
case 'T':
$this->setNodeAddress( [ 'https://testnode1.wavesnodes.com', 'https://testnode2.wavesnodes.com',
'https://testnode3.wavesnodes.com', 'https://testnode4.wavesnodes.com' ] );
$this->setNodeAddress( [
'https://nodes-testnet.wavesnodes.com',
'https://testnode1.wavesnodes.com',
'https://testnode2.wavesnodes.com',
'https://testnode4.wavesnodes.com',
] );
break;
default:
break;
}
}

$this->fetcher->setTimeoutConnect( $this->curlTimeout )->setTimeoutExec( $this->curlTimeout )->setOptions( $this->curlOptions );
}

public $matcher;
Expand Down

0 comments on commit 6f3432b

Please sign in to comment.