From: Roland Häder Date: Fri, 6 Nov 2020 15:31:04 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=90792a5f0551fd9cf29afd35cb3343b5ab741b66;p=hub.git Continued: - $minableInstance moved to BaseMinerProducer - $peerSuffix can be empty Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 40a576dd3..787cb8cf3 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -12,7 +12,6 @@ use Org\Shipsimu\Hub\Information\ShareableInfo; use Org\Shipsimu\Hub\Listener\BaseListener; use Org\Shipsimu\Hub\Listener\Listenable; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; -use Org\Shipsimu\Hub\Miner\Minable; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\Fragmentable; @@ -132,11 +131,6 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface */ private $packageInstance = NULL; - /** - * A Minable instance - */ - private $minableInstance = NULL; - /** * Name of used protocol */ @@ -298,7 +292,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface * @param $privateKey The new private key * @return void */ - protected final function setPrivateKey ($privateKey) { + protected final function setPrivateKey (string $privateKey) { // Set it config now $this->getConfigInstance()->setConfigEntry('private_key', (string) $privateKey); } @@ -319,9 +313,9 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface * @param $privateKeyHash The new private key hash * @return void */ - protected final function setNodePrivateKeyHash ($privateKeyHash) { + protected final function setNodePrivateKeyHash (string $privateKeyHash) { // Set it config now - $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash); + $this->getConfigInstance()->setConfigEntry('private_key_hash', $privateKeyHash); } /** @@ -340,8 +334,8 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface * @param $sessionId The new session id * @return void */ - protected final function setSessionId ($sessionId) { - $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId); + protected final function setSessionId (string $sessionId) { + $this->getConfigInstance()->setConfigEntry('session_id', $sessionId); } /** @@ -507,23 +501,4 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface return $this->packageInstance; } - /** - * Setter for Minable instance - * - * @param $minableInstance A Minable instance - * @return void - */ - protected final function setMinableInstance (Minable $minableInstance) { - $this->minableInstance = $minableInstance; - } - - /** - * Getter for minable instance - * - * @return $minableInstance A Minable instance - */ - protected final function getMinableInstance () { - return $this->minableInstance; - } - } diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index be43cdbcb..26833d6c5 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -349,16 +349,12 @@ abstract class BaseListener extends BaseHubSystem implements Visitable { * * @param $peerSuffix Suffix for peer name (e.g. :0 for TCP(/UDP?) connections) * @return void - * @throws InvalidArgumentException If $peerSuffix is empty * @throws LogicException If no info instance can be created */ protected function doListenSocketSelect (string $peerSuffix) { // Validate parameter and socket instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: peerSuffix=%s - CALLED!', strtoupper($this->getProtocolName()), $peerSuffix)); - if (empty($peerSuffix)) { - // Throw exception - throw new InvalidArgumentException('peerSuffix is empty'); - } elseif(!$this->getSocketInstance()->isValidSocket()) { + if(!$this->getSocketInstance()->isValidSocket()) { // Invalid socket throw new LogicException(sprintf('this->socketInstance->socketResource=%s is not valid', $this->getSocketInstance()->getSocketResource())); } diff --git a/application/hub/classes/producer/miner/class_BaseMinerProducer.php b/application/hub/classes/producer/miner/class_BaseMinerProducer.php index edb2e3d7e..037a109f3 100644 --- a/application/hub/classes/producer/miner/class_BaseMinerProducer.php +++ b/application/hub/classes/producer/miner/class_BaseMinerProducer.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Producer\Miner; // Import application-specific stuff +use Org\Shipsimu\Hub\Miner\Minable; use Org\Shipsimu\Hub\Producer\BaseProducer; // Import framework stuff @@ -31,6 +32,12 @@ use Org\Mxchange\CoreFramework\Registry\GenericRegistry; * along with this program. If not, see . */ abstract class BaseMinerProducer extends BaseProducer { + + /** + * A Minable instance + */ + private $minableInstance = NULL; + /** * Protected constructor * @@ -48,4 +55,23 @@ abstract class BaseMinerProducer extends BaseProducer { $minerInstance->blockProducerHasInitialized($this); } + /** + * Setter for Minable instance + * + * @param $minableInstance A Minable instance + * @return void + */ + protected final function setMinableInstance (Minable $minableInstance) { + $this->minableInstance = $minableInstance; + } + + /** + * Getter for minable instance + * + * @return $minableInstance A Minable instance + */ + protected final function getMinableInstance () { + return $this->minableInstance; + } + }