Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

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.3 2004/05/19 15:56:25 mmarsh Exp $
00008 //
00009 // $Log: StateInfo.h,v $
00010 // Revision 1.3  2004/05/19 15:56:25  mmarsh
00011 // Added copyright and license statements.
00012 //
00013 // Revision 1.2  2003/11/04 22:31:46  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #ifndef __CODEX_APSS_STATEINFO_H__
00019 #define __CODEX_APSS_STATEINFO_H__
00020 
00021 #include <vector>
00022 #include <map>
00023 
00024 #include "CODEX_Server/ServerState.h"
00025 #include "Message.h"
00026 #include "Types.h"
00027 #include "SecretManagement.h"
00028 #include "APSSShareCallback.h"
00029 #include "MessageDeliverer.h"
00030 
00034 namespace CODEX_APSS
00035 {
00036    class CODEX_VSS::Range;
00037 
00048    class StateInfo
00049    {
00050          //==========================================================
00051          // CONFIGURATION
00052          //==========================================================
00053 
00054       private :
00055 
00056       public :
00057 
00058          //==========================================================
00059          // TYPEDEFs
00060          //==========================================================
00061 
00066          typedef map< unsigned int, SecretManagement >     SecretManagementMap;
00067 
00069          const static unsigned int  NumShares = LabelType::NumShares;
00070 
00072          const static unsigned int  NumServers =
00073          CODEX_Server::ServerState::nServers;
00074 
00075 
00076          //==========================================================
00077          // UNIQUE INSTANCE
00078          //==========================================================
00079          
00081          static StateInfo* instance();
00082 
00084          static void destroy();
00085 
00086 
00087          //==========================================================
00088          // APSS CONFIGURATION
00089          //==========================================================
00090 
00092          void configure( const CONF* conf,
00093                          const char* sec,
00094                          const string& fname );
00095 
00097          void setDomain( unsigned char d ) { m_domain = d; }
00098 
00100          unsigned char domain() const { return m_domain; }
00101 
00107          void setMessageDeliverer( MessageDeliverer* deliverer )
00108          {
00109             m_deliverer = deliverer;
00110          }
00111 
00112 
00113          //==========================================================
00114          // SHARE MANAGEMENT
00115          //==========================================================
00116 
00118          unsigned int refreshInterval() const { return m_refreshInterval; }
00119 
00123          void addSharing( LSType* sharing );
00124 
00140          const LSType& sharing( const LSType::LabelType& label,
00141                                 unsigned int server ) const;
00142 
00149          const WitnessType& witness( unsigned int num ) const;
00150 
00163          const ShareSetType& subsharing( const SublabelType& sublabel,
00164                                          unsigned int server ) const;
00165 
00172          void addSubsharing( const SublabelType& sublabel,
00173                              const ShareType& subsharing );
00174 
00180          void recover( const SublabelType& sublabel );
00181 
00189          void markRecovered( const SublabelType& sublabel );
00190 
00197          SubshareList& splittings( const LabelType& label );
00198 
00205          const CODEX_VSS::Range& subshareRange( unsigned int num ) const;
00206 
00217          void updateExpired();
00218 
00226          void updateAll();
00227 
00235          bool addInitMsg( const SignedInitMsg& im );
00236 
00244          bool addEstablishMsg( const SignedEstablishMsg& em );
00245 
00253          bool addComputeMsg( const SignedComputeMsg& cm );
00254 
00265          bool addFinishedMsg( const SignedFinishedMsg& fm );
00266 
00275          bool addInitResponse( const SignedContributeMsg& cm );
00276 
00285          bool addEstablishResponse( const SignedEstablishedMsg& em );
00286 
00295          bool addComputeResponse( const SignedComputedMsg& cm );
00296 
00303          void clearEstablishMsgs( unsigned int num );
00304 
00313          void clearEstablishMsgs( unsigned int num, unsigned int establisher );
00314 
00322          unsigned long version( unsigned int num ) const;
00323 
00335          const InitRecord& initRecord( unsigned int num,
00336                                        unsigned int i ) const;
00337 
00352          const EstablishRecord& establishRecord(
00353             unsigned int num,
00354             unsigned int establisher,
00355             unsigned int shareNum,
00356             const LabelType& label ) const;
00357 
00369          const ComputeRecord& computeRecord( unsigned int num,
00370                                              unsigned int i ) const;
00371 
00384          const SignedFinishedMsg& finishedMsg( unsigned int num,
00385                                                unsigned int i ) const;
00386 
00394          void sendFinished( unsigned int num, unsigned int server ) const;
00395 
00402          void sendFinished( unsigned int num,
00403                             unsigned int coord,
00404                             unsigned int server ) const;
00405 
00415          void sendTo( unsigned int server,
00416                       const CODEX_Quorum::Message& message );
00417 
00427          void broadcast( const CODEX_Quorum::Message& message,
00428                          CODEX_Quorum::ResponseCallback* cb );
00429 
00430       protected :
00432          StateInfo();
00433 
00435          virtual ~StateInfo();
00436 
00438          static StateInfo* m_instance;
00439 
00441          void checkSecretNum( unsigned int num ) const;
00442 
00443       private :
00444          typedef list< SublabelType >  RecoveryList;
00445 
00446          unsigned char        m_domain;
00447          unsigned int         m_refreshInterval;
00448          SecretManagementMap  m_secrets;
00449          CODEX_VSS::Range*    m_rsaSubshareRange;
00450          CODEX_VSS::Range*    m_elgamalSubshareRange;
00451          APSSShareCallback*   m_rsaCallback;
00452          APSSShareCallback*   m_elgamalCallback;
00453          unsigned long        m_interval;
00454          MessageDeliverer*    m_deliverer;
00455          RecoveryList         m_recoverLabels;
00456    };
00457 }
00458 
00459 #endif /* __CODEX_APSS_STATEINFO_H__ */

Generated on Wed Jun 2 16:32:56 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18