states.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:zatt 作者: simonacca 项目源码 文件源码
def on_peer_response_append(self, peer, msg):
        """Handle peer response to append_entries.
        If successful RPC, try to commit new entries.
        If RPC unsuccessful, backtrack."""
        if msg['success']:
            self.matchIndex[peer] = msg['matchIndex']
            self.nextIndex[peer] = msg['matchIndex'] + 1

            self.matchIndex[self.volatile['address']] = self.log.index
            self.nextIndex[self.volatile['address']] = self.log.index + 1
            index = statistics.median_low(self.matchIndex.values())
            self.log.commit(index)
            self.send_client_append_response()
        else:
            self.nextIndex[peer] = max(0, self.nextIndex[peer] - 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号