]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 29 Oct 2020 10:50:42 +0000 (11:50 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 29 Oct 2020 10:55:13 +0000 (11:55 +0100)
- sorted members
- public static methods are always there, no need to have them in interfaces

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php
application/hub/classes/helper/connection/class_BaseConnectionHelper.php
application/hub/classes/resolver/state/peer/class_PeerStateResolver.php
application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php
application/hub/interfaces/helper/connections/class_ConnectionHelper.php
application/hub/interfaces/resolver/state/class_StateResolver.php

index 6bfa6fb15ba0b573c667f28565e00115b78f99be..b5479aa1911060272ee2d04844e9e6ce5c86dacc 100644 (file)
@@ -144,15 +144,6 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp
                return $searchInstance;
        }
 
-       /**
-        * Getter for result instance for unpublished entries
-        *
-        * @return      $unpublishedEntriesInstance             Result instance
-        */
-       public final function getUnpublishedEntriesInstance () {
-               return $this->unpublishedEntriesInstance;
-       }
-
        /**
         * Prepares a "local" instance of a StoreableCriteria class with all node
         * data for insert/update queries. This data set contains data from *this*
@@ -207,6 +198,15 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp
                return $dataSetInstance;
        }
 
+       /**
+        * Getter for result instance for unpublished entries
+        *
+        * @return      $unpublishedEntriesInstance             Result instance
+        */
+       public final function getUnpublishedEntriesInstance () {
+               return $this->unpublishedEntriesInstance;
+       }
+
        /**
         * Checks whether the local (*this*) node is registered in the DHT by
         * checking if the external address is found.
index 1fce55633dd92bd8bc3b76285c7f585d17759b6d..172c201b2998d7561231bee1381aafd4414bb7d9 100644 (file)
@@ -228,7 +228,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                        if ($helperInstance->getStateInstance() instanceof PeerStateable && $helperInstance->getPrintableState() !== $socketInstance->translateLastSocketErrorCodeToName()) {
                                // Resolve the peer's state (but ignore return value)
                                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
-                               PeerStateResolver::resolveStateByPackage($helperInstance, $packageInstance, $socketInstance);
+                               PeerStateResolver::createStateByPackageInstance($helperInstance, $packageInstance, $socketInstance);
                        }
                } catch (InvalidSocketException $e) {
                        // This cannot be fixed, so log it away
index ef78abe867c5736ad918fa90651d1ac7670900cc..9c2c87c72e893081b246e6afea3e94a84961f502 100644 (file)
@@ -113,45 +113,24 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
         */
        public final function __toString () {
                // Class name representation
-               $class = self::getConnectionClassNameFromSocket($this->getSocketInstance(), parent::__toString());
+               $class = $this->getConnectionClassNameFromSocket();
 
                // Return it
                return $class;
        }
 
-       /**
-        * Setter for isInitialized
-        *
-        * @param       $isInitialized          Name of used protocol in this connection
-        * @return      void
-        */
-       protected final function setIsInitialized ($isInitialized) {
-               $this->isInitialized = $isInitialized;
-       }
-
-       /**
-        * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!)
-        *
-        * @return      $isInitialized          Name of used protocol in this connection
-        */
-       protected final function isInitialized () {
-               return $this->isInitialized;
-       }
-
        /**
         * Static "getter" for this connection class' name
         *
-        * @param       $socketInstance         An instance of a StorableSocket class
-        * @param       $className                      Name of calling class
         * @return      $class          Expanded class name
         */
-       public static function getConnectionClassNameFromSocket (StorableSocket $socketInstance, $className) {
+       private function getConnectionClassNameFromSocket () {
                // Get recipient address/port
-               $recipientAddress = $socketInstance->getSocketRecipientAddress();
-               $recipientPort = $socketInstance->getSocketRecipientPort();
+               $recipientAddress = $this->getSocketInstance()->getSocketRecipientAddress();
+               $recipientPort = $this->getSocketInstance()->getSocketRecipientPort();
 
                // Construct it
-               $class = sprintf('%s:%d:%s', $recipientAddress, $recipientPort, $className);
+               $class = sprintf('%s:%d:%s', $recipientAddress, $recipientPort, parent::__toString());
 
                // ... and return it
                return $class;
@@ -219,6 +198,25 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                return $rawData;
        }
 
+       /**
+        * Setter for isInitialized
+        *
+        * @param       $isInitialized          Name of used protocol in this connection
+        * @return      void
+        */
+       protected final function setIsInitialized ($isInitialized) {
+               $this->isInitialized = $isInitialized;
+       }
+
+       /**
+        * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!)
+        *
+        * @return      $isInitialized          Name of used protocol in this connection
+        */
+       protected final function isInitialized () {
+               return $this->isInitialized;
+       }
+
        /**
         * "Accept" a visitor by simply calling it back
         *
index 42ebd2fc949065d24eb44ce59a598e0fa428fe36..96a7e33713806ed0ecc91be34af6ca580d34b3c3 100644 (file)
@@ -72,7 +72,7 @@ class PeerStateResolver extends BaseStateResolver implements StateResolver {
         * @throws      InvalidSocketException  If socketResource, even from getSocketResource() is no valid resource
         * @todo        ~30% done
         */
-       public static function resolveStateByPackage (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
+       public static function createStateByPackageInstance (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
                // Get temporary resolver instance
                $resolverInstance = self::createPeerStateResolver();
 
index f7c74349efbb699179eec38339299fddb9111973..237a24e821678adb943d6170d85791c8847b2413 100644 (file)
@@ -33,13 +33,6 @@ use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface NodeDhtWrapper extends DatabaseWrapper {
-       /**
-        * Static getter for an array of all DHT database entries
-        *
-        * @return      $elements       All elements for the DHT dabase
-        */
-       static function getAllElements ();
-
        /**
         * Getter for result instance for unpublished entries
         *
@@ -63,7 +56,7 @@ interface NodeDhtWrapper extends DatabaseWrapper {
        function registerLocalNode ();
 
        /**
-        * Updates local (*this*) node data in DHT, this is but not limited to the
+        * Updates local (*this*) node's data in DHT, this is but not limited to the
         * session id, ip number (and/or hostname) and port number.
         *
         * @return      void
@@ -145,18 +138,18 @@ interface NodeDhtWrapper extends DatabaseWrapper {
        function initEntryPublication ();
 
        /**
-        * Removes non-data from given array.
+        * Removes non-public data from given array.
         *
-        * @param       $data   An array with possible non-data that needs to be removed.
-        * @return      $data   A cleaned up array with only data.
+        * @param       $data   An array with possible non-public data that needs to be removed.
+        * @return      $data   A cleaned up array with only public data.
         */
        function removeNonPublicDataFromArray(array $data);
 
        /**
-        * Find recipients for given package data and returns it as a result instance
+        * Find recipients for given package data and exclude the sender
         *
         * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      $recipients             An indexed array with DHT recipients
+        * @return      $recipients                     An indexed array with DHT recipients
         */
        function getResultFromExcludedSender (DeliverablePackage $packageInstance);
 
index 58f0ea6db86693a3af1ef9c6d65ddd195924132b..fe65e72e6590345a687e4303899d9760a4742373 100644 (file)
@@ -49,15 +49,6 @@ interface ConnectionHelper extends HubHelper {
         */
        function doShutdown ();
 
-       /**
-        * Static "getter" for this connection class' name
-        *
-        * @param       $socketInstance         An instance of a StorableSocket class
-        * @param       $className      Name of calling class
-        * @return      $class  Expanded class name
-        */
-       static function getConnectionClassNameFromSocket (StorableSocket $socketInstance, $className);
-
        /**
         * Getter for shuttedDown
         *
index d00d4a23ea9ec039e664d654ec30365fdd533f87..ff33a008537944ad5a3acbb88fa7a7a64b4c0c21 100644 (file)
@@ -2,11 +2,6 @@
 // Own namespace
 namespace Org\Shipsimu\Hub\Resolver\State;
 
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Resolver\Resolver;
 
@@ -33,16 +28,6 @@ use Org\Mxchange\CoreFramework\Resolver\Resolver;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface StateResolver extends Resolver {
-       /**
-        * Returns an state instance for a given package raw data and socket resource
-        *
-        * @param       $helperInstance         An instance of a ConnectionHelper class
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @param       $socketInstance         An instance of a StorableSocket class
-        * @return      $stateInstance          An instance of a PeerStateable class
-        */
-       static function resolveStateByPackage (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance);
-
        /**
         * Checks whether the given state is valid
         *