コード例 #1
0
ファイル: netconfig.py プロジェクト: zxgdhd/sawtooth-core
 def set_peers(self, peer_mat):
     if self.peer_mat is not None:
         raise Exception('validator configuration is static')
     self.peer_mat = AdjacencyMatrix(self.n_mag, peer_mat)
     mat = self.peer_mat.get_mat()
     for (nd_idx, nd) in enumerate(self.nodes):
         nd['Peers'] = []
         for (peer_idx, is_peer) in enumerate(mat[nd_idx]):
             if is_peer == 1 and peer_idx != nd_idx:
                 nd['Peers'].append(self.nodes[peer_idx]['NodeName'])
コード例 #2
0
ファイル: netconfig.py プロジェクト: zxgdhd/sawtooth-core
 def set_quorum(self, quorum_mat):
     if self.quorum_mat is not None:
         raise Exception('validator configuration is static')
     self.quorum_mat = AdjacencyMatrix(self.n_mag, quorum_mat)
     mat = self.quorum_mat.get_mat()
     for (nd_idx, nd) in enumerate(self.nodes):
         nd['Quorum'] = []
         for (quorum_idx, in_quorum) in enumerate(mat[nd_idx]):
             if in_quorum == 1:
                 nd['Quorum'].append(self.nodes[quorum_idx]['NodeName'])
コード例 #3
0
ファイル: netconfig.py プロジェクト: zxgdhd/sawtooth-core
 def set_nodes(self, node_mat):
     if self.node_mat is not None:
         raise Exception('validator configuration is static')
     self.node_mat = AdjacencyMatrix(self.n_mag, node_mat)
     mat = self.node_mat.get_mat()
     for (this_idx, this) in enumerate(self.nodes):
         this['Nodes'] = []
         for (other_idx, add_other) in enumerate(mat[this_idx]):
             if add_other == 1:
                 this['Nodes'].append(self._get_gossip_info(other_idx))
コード例 #4
0
ファイル: netconfig.py プロジェクト: zxgdhd/sawtooth-core
 def set_blacklist(self, blacklist_mat=None):
     if self.blacklist_mat is not None:
         raise Exception('validator configuration is static')
     if blacklist_mat is None:
         assert self.peer_mat is not None
         blacklist_mat = self.peer_mat.negate()
     self.blacklist_mat = AdjacencyMatrix(self.n_mag, blacklist_mat)
     mat = self.blacklist_mat.get_mat()
     for (nd_idx, nd) in enumerate(self.nodes):
         nd['Blacklist'] = []
         for (exclude_idx, is_exclude) in enumerate(mat[nd_idx]):
             if is_exclude == 1:
                 exclude = self._get_gossip_info(exclude_idx)
                 nd['Blacklist'].append(exclude['Identifier'])