]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 6 Nov 2020 15:31:04 +0000 (16:31 +0100)
committerRoland Häder <roland@mxchange.org>
Fri, 6 Nov 2020 15:31:04 +0000 (16:31 +0100)
- $minableInstance moved to BaseMinerProducer
- $peerSuffix can be empty

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/listener/class_BaseListener.php
application/hub/classes/producer/miner/class_BaseMinerProducer.php

index 40a576dd303c7724cb7c11376199293bf0552c78..787cb8cf314682b023dda660ead62a697c6d8481 100644 (file)
@@ -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;
-       }
-
 }
index be43cdbcb4e7c75b9c9d93489072a3d22b1af83b..26833d6c529e55ddad5daa3d6a2c1a41a8b1ab32 100644 (file)
@@ -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()));
                }
index edb2e3d7e83c988dc8d2114857b2d670290d29c2..037a109f38ee0678bd8050c5b9da547320257069 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
  */
 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;
+       }
+
 }