示例#1
0
    def __init__(self, node, **kwargs):
        """Constructor for the DevModeJournal class.

        Args:
            node (Node): The local node.
        """
        super(DevModeJournal, self).__init__(node, **kwargs)

        # the one who can publish blocks is always the genesis ledger
        self.block_publisher = self.GenesisLedger
        self.block_wait_time = 1
        if 'BlockWaitTime' in kwargs:
            self.block_wait_time = kwargs["BlockWaitTime"]

        # default invalid block wait times to 1 second setting to
        if not isinstance(self.block_wait_time, (int, long)):
            self.block_wait_time = 1

        self.next_block_time = time()
        self.onHeartbeatTimer += self._check_claim_block

        # initialize the block handlers
        dev_mode_transaction_block.register_message_handlers(self)

        # initialize stats specifically for the block chain journal
        self.JournalStats.add_metric(stats.Counter('BlocksClaimed'))
示例#2
0
    def _init_gossip_stats(self, stat_domains):
        self.PacketStats = stats.Stats(self.LocalNode.Name, 'packet')
        self.PacketStats.add_metric(stats.Average('BytesSent'))
        self.PacketStats.add_metric(stats.Average('BytesReceived'))
        self.PacketStats.add_metric(stats.Counter('MessagesAcked'))
        self.PacketStats.add_metric(stats.Counter('DuplicatePackets'))
        self.PacketStats.add_metric(stats.Counter('DroppedPackets'))
        self.PacketStats.add_metric(stats.Counter('AcksReceived'))
        self.PacketStats.add_metric(stats.Counter('MessagesHandled'))
        self.PacketStats.add_metric(stats.Sample(
            'UnackedPacketCount', lambda: len(self.PendingAckMap)))

        self.MessageStats = stats.Stats(self.LocalNode.Name, 'message')
        self.MessageStats.add_metric(stats.MapCounter('MessageType'))
        if stat_domains is not None:
            stat_domains['packet'] = self.PacketStats
            stat_domains['message'] = self.MessageStats
示例#3
0
    def _initgossipstats(self):
        self.PacketStats = stats.Stats(self.LocalNode.Name, 'packet')
        self.PacketStats.add_metric(stats.Average('BytesSent'))
        self.PacketStats.add_metric(stats.Average('BytesReceived'))
        self.PacketStats.add_metric(stats.Counter('MessagesAcked'))
        self.PacketStats.add_metric(stats.Counter('DuplicatePackets'))
        self.PacketStats.add_metric(stats.Counter('DroppedPackets'))
        self.PacketStats.add_metric(stats.Counter('AcksReceived'))
        self.PacketStats.add_metric(stats.Counter('MessagesHandled'))
        self.PacketStats.add_metric(
            stats.Sample('UnackedPacketCount',
                         lambda: len(self.PendingAckMap)))

        self.MessageStats = stats.Stats(self.LocalNode.Name, 'message')
        self.MessageStats.add_metric(stats.MapCounter('MessageType'))

        self.StatDomains = {
            'packet': self.PacketStats,
            'message': self.MessageStats
        }
示例#4
0
    def _initledgerstats(self):
        self.JournalStats = stats.Stats(self.LocalNode.Name, 'ledger')
        self.JournalStats.add_metric(stats.Counter('CommitedBlockCount'))
        self.JournalStats.add_metric(stats.Counter('CommitedTxnCount'))
        self.JournalStats.add_metric(
            stats.Sample('PendingBlockCount', lambda: self.PendingBlockCount))
        self.JournalStats.add_metric(
            stats.Sample('PendingTxnCount', lambda: self.PendingTxnCount))

        self.StatDomains['ledger'] = self.JournalStats

        self.JournalConfigStats = stats.Stats(self.LocalNode.Name,
                                              'ledgerconfig')
        self.JournalConfigStats.add_metric(
            stats.Sample('MinimumTransactionsPerBlock',
                         lambda: self.MinimumTransactionsPerBlock))
        self.JournalConfigStats.add_metric(
            stats.Sample('MaximumTransactionsPerBlock',
                         lambda: self.MaximumTransactionsPerBlock))

        self.StatDomains['ledgerconfig'] = self.JournalConfigStats
示例#5
0
    def __init__(self, node, **kwargs):
        """Constructor for the PoetJournal class.

        Args:
            node (Node): The local node.
        """
        super(PoetJournal, self).__init__(node, **kwargs)

        enclave_module = None
        if 'PoetEnclaveImplementation' in kwargs:
            enclave_module = kwargs['PoetEnclaveImplementation']
        else:
            enclave_module = 'journal.consensus.poet.poet_enclave_simulator' \
                             '.poet_enclave_simulator'

        poet_enclave = importlib.import_module(enclave_module)
        poet_enclave.initialize(**kwargs)
        WaitCertificate.poet_enclave = poet_enclave
        WaitTimer.poet_enclave = poet_enclave

        self.onHeartbeatTimer += self._check_certificate

        # initialize the poet handlers
        poet_transaction_block.register_message_handlers(self)

        # initialize stats specifically for the block chain journal
        self.JournalStats.add_metric(stats.Counter('BlocksClaimed'))
        self.JournalStats.add_metric(stats.Value('LocalMeanTime', 0))
        self.JournalStats.add_metric(stats.Value('PreviousBlockID', '0'))
        self.JournalStats.add_metric(stats.Value('AggregateLocalMean', '0'))
        self.JournalStats.add_metric(stats.Value('PopulationEstimate', '0'))
        self.JournalStats.add_metric(stats.Counter('InvalidTxnCount'))
        self.JournalStats.add_metric(stats.Value('ExpectedExpirationTime',
                                                 '0'))
        self.JournalStats.add_metric(stats.Value('Duration', '0'))

        # propagate the maximum blocks to keep
        self.MaximumBlocksToKeep = max(self.MaximumBlocksToKeep,
                                       WaitTimer.certificate_sample_length)
示例#6
0
    def __init__(self, node, **kwargs):
        """Constructor for the PoetJournal class.

        Args:
            node (Node): The local node.
        """
        super(PoetJournal, self).__init__(node, **kwargs)

        self.onHeartbeatTimer += self._check_certificate

        # initialize the poet handlers
        poet_transaction_block.register_message_handlers(self)

        # initialize stats specifically for the block chain journal
        self.JournalStats.add_metric(stats.Counter('BlocksClaimed'))

        # propagate the maximum blocks to keep
        self.MaximumBlocksToKeep = max(self.MaximumBlocksToKeep,
                                       WaitTimer.CertificateSampleLength)