コード例 #1
0
ファイル: node.py プロジェクト: venkatAnne/sawtooth-core
    def __init__(self,
                 address=(None, None),
                 identifier=None,
                 signingkey=None,
                 name=None,
                 rate=None,
                 capacity=None,
                 endpoint_address=(None, None)):
        """Constructor for the Node class.

        Args:
            address (ordered pair of str, int): address of the node in the
                form of (host, port).  This is the local address to which the
                node is bound.
            identifier (str): an identifier for the node.
            signingkey (str): used to create a signing key, in PEM format.
            name (str): a short, human-readable name for the node.
            rate (int): the number of tokens to be added to the TokenBucket
                per drip.
            capacity (int): the total capacity of tokens in the node's
                TokenBucket.
            endpoint_address (ordered pair of str, int): the publicly-
                reachable address of the node in the form of (host, port).
                If the node is publicly-reachable, this should be the same as
                address.  If not, this is the address at the NAT used to route
                to address.
        """

        self.NetHost = address[0]
        self.NetPort = address[1]
        self._endpoint_host = endpoint_address[0]
        self._endpoint_port = endpoint_address[1]

        self.SigningKey = signingkey
        self.Identifier = identifier

        self.Name = name if name else self.Identifier[:8]
        self.is_peer = False

        self.Estimator = RoundTripEstimator()
        self.MessageQ = TransmissionQueue()
        self.TokenBucket = token_bucket.TokenBucket(rate, capacity)

        self.FixedRandomDelay = random.uniform(*self.DelayRange)
        if self.UseFixedDelay:
            self.Delay = self._fixeddelay
        else:
            self.Delay = self._randomdelay
        self.Stats = None

        self.MissedTicks = 0
コード例 #2
0
ファイル: node.py プロジェクト: stanliberman/sawtooth-core
    def __init__(self,
                 address=(None, None),
                 identifier=None,
                 signingkey=None,
                 name=None,
                 rate=None,
                 capacity=None):
        """Constructor for the Node class.

        Args:
            address (ordered pair of str): address of the node in the form
                of (host, port).
            identifier (str): an identifier for the node.
            signingkey (str): used to create a signing key, in PEM format.
            name (str): a short, human-readable name for the node.
            rate (int): the number of tokens to be added to the TokenBucket
                per drip.
            capacity (int): the total capacity of tokens in the node's
                TokenBucket.
        """

        self.NetHost = address[0]
        self.NetPort = address[1]

        self.SigningKey = signingkey
        self.Identifier = identifier

        self.Name = name if name else self.Identifier[:8]
        self.Enabled = False

        self.Estimator = RoundTripEstimator()
        self.MessageQ = TransmissionQueue()
        self.TokenBucket = token_bucket.TokenBucket(rate, capacity)

        self.FixedRandomDelay = random.uniform(*self.DelayRange)
        if self.UseFixedDelay:
            self.Delay = self._fixeddelay
        else:
            self.Delay = self._randomdelay
        self.Stats = None

        self.MissedTicks = 0