• JerryLucy
    了解作者
  • Java
    开发工具
  • 8.9MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2019-05-20 15:15
    上传日期
完整Eclipse BFT-SMart工程
BFT-Smart.rar
内容介绍
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package bftsmart.tom.core; import bftsmart.communication.ServerCommunicationSystem; import bftsmart.consensus.Decision; import bftsmart.consensus.Epoch; import bftsmart.consensus.Consensus; import bftsmart.consensus.TimestampValuePair; import bftsmart.consensus.messages.ConsensusMessage; import bftsmart.consensus.messages.MessageFactory; import bftsmart.consensus.roles.Acceptor; import bftsmart.reconfiguration.ServerViewController; import bftsmart.statemanagement.StateManager; import bftsmart.tom.core.messages.TOMMessage; import bftsmart.tom.leaderchange.RequestsTimer; import bftsmart.tom.leaderchange.CollectData; import bftsmart.tom.leaderchange.LCManager; import bftsmart.tom.leaderchange.LCMessage; import bftsmart.tom.leaderchange.CertifiedDecision; import bftsmart.tom.util.BatchBuilder; import bftsmart.tom.util.BatchReader; import bftsmart.tom.util.TOMUtil; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.security.MessageDigest; import java.security.SignedObject; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * This class implements the synchronization phase described in * Joao Sousa's 'From Byzantine Consensus to BFT state machine replication: a latency-optimal transformation' (May 2012) * * This class implements all optimizations described at the end of the paper * * @author joao */ public class Synchronizer { private Logger logger = LoggerFactory.getLogger(this.getClass()); // out of context messages related to the leader change are stored here private final HashSet<LCMessage> outOfContextLC; // Manager of the leader change private final LCManager lcManager; //Total order layer private final TOMLayer tom; // Stuff from TOMLayer that this object needs private final RequestsTimer requestsTimer; private final ExecutionManager execManager; private final ServerViewController controller; private final BatchBuilder bb; private final ServerCommunicationSystem communication; private final StateManager stateManager; private final Acceptor acceptor; private final MessageDigest md; // Attributes to temporarely store synchronization info // if state transfer is required for synchronization private int tempRegency = -1; private CertifiedDecision tempLastHighestCID = null; private HashSet<SignedObject> tempSignedCollects = null; private byte[] tempPropose = null; private int tempBatchSize = -1; private boolean tempIAmLeader = false; public Synchronizer(TOMLayer tom) { this.tom = tom; this.requestsTimer = this.tom.requestsTimer; this.execManager = this.tom.execManager; this.controller = this.tom.controller; this.bb = this.tom.bb; this.communication = this.tom.getCommunication(); this.stateManager = this.tom.stateManager; this.acceptor = this.tom.acceptor; this.md = this.tom.md; this.outOfContextLC = new HashSet<>(); this.lcManager = new LCManager(this.tom,this.controller, this.md); } public LCManager getLCManager() { return lcManager; } /** * This method is called when there is a timeout and the request has already * been forwarded to the leader * * @param requestList List of requests that the replica wanted to order but * didn't manage to */ public void triggerTimeout(List<TOMMessage> requestList) { ObjectOutputStream out = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); int regency = lcManager.getNextReg(); requestsTimer.stopTimer(); requestsTimer.Enabled(false); // still not in the leader change phase? if (lcManager.getNextReg() == lcManager.getLastReg()) { lcManager.setNextReg(lcManager.getLastReg() + 1); // define next timestamp regency = lcManager.getNextReg(); // update variable // store messages to be ordered lcManager.setCurrentRequestTimedOut(requestList); // store information about messages that I'm going to send lcManager.addStop(regency, this.controller.getStaticConf().getProcessId()); //execManager.stop(); // stop consensus execution //Get requests that timed out and the requests received in STOP messages //and add those STOPed requests to the client manager addSTOPedRequestsToClientManager(); List<TOMMessage> messages = getRequestsToRelay(); try { // serialize content to send in STOP message out = new ObjectOutputStream(bos); if (messages != null && messages.size() > 0) { //TODO: If this is null, then there was no timeout nor STOP messages. //What to do? byte[] serialized = bb.makeBatch(messages, 0, 0, controller.getStaticConf().getUseSignatures() == 1); out.writeBoolean(true); out.writeObject(serialized); } else { out.writeBoolean(false); logger.warn("Strange... did not include any request in my STOP message for regency " + regency); } out.flush(); bos.flush(); byte[] payload = bos.toByteArray(); out.close(); bos.close(); // send STOP-message logger.info("Sending STOP message to install regency " + regency + " with " + (messages != null ? messages.size() : 0) + " request(s) to relay"); LCMessage stop = new LCMessage(this.controller.getStaticConf().getProcessId(), TOMUtil.STOP, regency, payload); requestsTimer.setSTOP(regency, stop); // make replica re-transmit the stop message until a new regency is installed communication.send(this.controller.getCurrentViewOtherAcceptors(), stop); } catch (IOException ex) { logger.error("Could not serialize STOP message", ex); } finally { try { out.close(); bos.close(); } catch (IOException ex) { logger.error("Could not serialize STOP message", ex); } } } processOutOfContextSTOPs(regency); // the replica might have received STOPs // that were out of context at the time they // were received, but now can be processed startSynchronization(regency); // evaluate STOP messages } // Processes STOP messages that were not process upon reception, because they were // ahead of the replica's expected regency private void processOutOfContextSTOPs(int regency) { logger.debug("Checking if there are out of context STOPs for regency " + regency); Set<LCMessage> stops = getOutOfContextLC(TOMUtil.STOP, regency); if (stops.size() > 0) { logger.info("Processing " + stops.size() + " out of context STOPs for regency " + regency); } else { lo
评论
    相关推荐
    • [8] Multimedia resource allocation in mmwave.rar
      [8] Multimedia resource allocation in mmwave
    • SMaRt-v0.6.zip
      BFT-smart是一个能拜占庭容错的状态机复制库,在Java下开发,具有简单性和鲁棒性。我们的主要目的是提供一个代码库,可用于建立可靠的服务,还扩展到创造新的协议。
    • 1.zip
      BlockChain in Medical Data
    • pact-lang-api
      此软件包可帮助您轻松与Pact的开发服务器和运行Pact的可伸缩BFT群集进行交互。 每个API都是相同的。 有关Pact和scalableBFT的信息,请参见或 。 有关用法示例,请参见 进口 pact-lang-api.js应该作为常规节点依赖项...
    • 并行SMR:在BFT-SMaRt之上实现的并行SMR
      并行状态机复制(SMR) 埃斯特projetoé嗯叉去 ,utilizado没有呐pesquisa documentada EM 。 信息通报,请咨询原始项目。 雀巢叉子forsen desenvolvidos: Uma nova carga de trabalho baseada em umdicioná...
    • eco-nft:环保CryptoArt(NFT)的基本指南
      环保CryptoArt(NFT)指南 介绍 本文不是全面的“初学者的CryptoArt”。 对于要在可持续平台上在区块链上创建和出售CryptoArtworks(或NFT)的冒险艺术家来说,这只是一个非常简短(尽可能)的第一步。...
    • core:Terra 协议的 GO 实现
      实现 Terra 协议的全节点软件 · · · · · 什么是泰拉? 是一种区块链协议,为去... Terra Core 构建在之上,并使用 BFT 共识。 如果您打算使用 Terra Core 源代码,建议您熟悉这些项目中的概念。 安装 二进
    • 很棒的去中心化论文:去中心化系统中的有影响力的论文(加密货币,合同,共识等)
      很棒的去中心化论文:去中心化系统中的有影响力的论文(加密货币,合同,共识等)
    • 区块链技术指南 .zip
      区块链技术指南 ,区块链技术 ,区块链技术指导
    • 区块链原理详解_附代码.zip
      了解区块链,区块链原理详解,还有代码,详情请自行下载,,,希望能帮助大家