Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CODEX_APSS/StateInfo.h

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: StateInfo.h,v 1.4 2005/01/21 19:44:15 mmarsh Exp $
00008 //
00009 // $Log: StateInfo.h,v $
00010 // Revision 1.4  2005/01/21 19:44:15  mmarsh
00011 // Updated for compatibility with Doxygen 1.4.1
00012 //
00013 // Revision 1.3  2004/05/19 15:56:25  mmarsh
00014 // Added copyright and license statements.
00015 //
00016 // Revision 1.2  2003/11/04 22:31:46  mmarsh
00017 // *** empty log message ***
00018 //
00019 //
00020 
00021 #ifndef __CODEX_APSS_STATEINFO_H__
00022 #define __CODEX_APSS_STATEINFO_H__
00023 
00024 #include <vector>
00025 #include <map>
00026 
00027 #include "CODEX_Server/ServerState.h"
00028 #include "Message.h"
00029 #include "Types.h"
00030 #include "SecretManagement.h"
00031 #include "APSSShareCallback.h"
00032 #include "MessageDeliverer.h"
00033 
00037 namespace CODEX_APSS
00038 {
00039    class CODEX_VSS::Range;
00040 
00051    class StateInfo
00052    {
00053          //==========================================================
00054          // CONFIGURATION
00055          //==========================================================
00056 
00057       private :
00058 
00059       public :
00060 
00061          //==========================================================
00062          // TYPEDEFs
00063          //==========================================================
00064 
00069          typedef map< unsigned int, SecretManagement >     SecretManagementMap;
00070 
00072          const static unsigned int  NumShares = LabelType::NumShares;
00073 
00075          const static unsigned int  NumServers =
00076          CODEX_Server::ServerState::nServers;
00077 
00078 
00079          //==========================================================
00080          // UNIQUE INSTANCE
00081          //==========================================================
00082          
00084          static StateInfo* instance();
00085 
00087          static void destroy();
00088 
00089 
00090          //==========================================================
00091          // APSS CONFIGURATION
00092          //==========================================================
00093 
00095          void configure( const CONF* conf,
00096                          const char* sec,
00097                          const string& fname );
00098 
00100          void setDomain( unsigned char d ) { m_domain = d; }
00101 
00103          unsigned char domain() const { return m_domain; }
00104 
00110          void setMessageDeliverer( MessageDeliverer* deliverer )
00111          {
00112             m_deliverer = deliverer;
00113          }
00114 
00115 
00116          //==========================================================
00117          // SHARE MANAGEMENT
00118          //==========================================================
00119 
00121          unsigned int refreshInterval() const { return m_refreshInterval; }
00122 
00126          void addSharing( LSType* sharing );
00127 
00143          const LSType& sharing( const LSType::LabelType& label,
00144                                 unsigned int server ) const;
00145 
00152          const WitnessType& witness( unsigned int num ) const;
00153 
00166          const ShareSetType& subsharing( const SublabelType& sublabel,
00167                                          unsigned int server ) const;
00168 
00175          void addSubsharing( const SublabelType& sublabel,
00176                              const ShareType& subsharing );
00177 
00183          void recover( const SublabelType& sublabel );
00184 
00192          void markRecovered( const SublabelType& sublabel );
00193 
00200          SubshareList& splittings( const LabelType& label );
00201 
00208          const CODEX_VSS::Range& subshareRange( unsigned int num ) const;
00209 
00220          void updateExpired();
00221 
00229          void updateAll();
00230 
00238          bool addInitMsg( const SignedInitMsg& im );
00239 
00247          bool addEstablishMsg( const SignedEstablishMsg& em );
00248 
00256          bool addComputeMsg( const SignedComputeMsg& cm );
00257 
00268          bool addFinishedMsg( const SignedFinishedMsg& fm );
00269 
00278          bool addInitResponse( const SignedContributeMsg& cm );
00279 
00288          bool addEstablishResponse( const SignedEstablishedMsg& em );
00289 
00298          bool addComputeResponse( const SignedComputedMsg& cm );
00299 
00306          void clearEstablishMsgs( unsigned int num );
00307 
00316          void clearEstablishMsgs( unsigned int num, unsigned int establisher );
00317 
00325          unsigned long version( unsigned int num ) const;
00326 
00338          const InitRecord& initRecord( unsigned int num,
00339                                        unsigned int i ) const;
00340 
00355          const EstablishRecord& establishRecord(
00356             unsigned int num,
00357             unsigned int establisher,
00358             unsigned int shareNum,
00359             const LabelType& label ) const;
00360 
00372          const ComputeRecord& computeRecord( unsigned int num,
00373                                              unsigned int i ) const;
00374 
00387          const SignedFinishedMsg& finishedMsg( unsigned int num,
00388                                                unsigned int i ) const;
00389 
00397          void sendFinished( unsigned int num, unsigned int server ) const;
00398 
00405          void sendFinished( unsigned int num,
00406                             unsigned int coord,
00407                             unsigned int server ) const;
00408 
00418          void sendTo( unsigned int server,
00419                       const CODEX_Quorum::Message& message );
00420 
00430          void broadcast( const CODEX_Quorum::Message& message,
00431                          CODEX_Quorum::ResponseCallback* cb );
00432 
00433       protected :
00435          StateInfo();
00436 
00438          virtual ~StateInfo();
00439 
00441          static StateInfo* m_instance;
00442 
00444          void checkSecretNum( unsigned int num ) const;
00445 
00446       private :
00447          typedef list< SublabelType >  RecoveryList;
00448 
00449          unsigned char        m_domain;
00450          unsigned int         m_refreshInterval;
00451          SecretManagementMap  m_secrets;
00452          CODEX_VSS::Range*    m_rsaSubshareRange;
00453          CODEX_VSS::Range*    m_elgamalSubshareRange;
00454          APSSShareCallback*   m_rsaCallback;
00455          APSSShareCallback*   m_elgamalCallback;
00456          unsigned long        m_interval;
00457          MessageDeliverer*    m_deliverer;
00458          RecoveryList         m_recoverLabels;
00459    };
00460 }
00461 
00462 #endif /* __CODEX_APSS_STATEINFO_H__ */

Generated on Fri May 6 17:41:27 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1