-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Fast incremental file transfer using Merkle-Hash-Trees -- @package sync-mht @version 0.3.6.0 module Sync.MerkleTree.Util.GetFromInputStream -- | Deserialize value from inputstream getFromInputStream :: Serialize a => InputStream ByteString -> IO a -- | This monad is used to increase the speed of communication between two -- processes - if there is latency. It works by using the -- non-deterministic part of the communication protocol to send multiple -- requests to the output-channel, before processing the responses from -- the input-channel. -- -- Considering the example -- --
-- foo = splitRequests [bar, baz] -- bar = do x <- request (GetSumOf 1 2) -- liftM Sum request (GetSumOf x 3) -- baz = liftM Sum request (GetSumOf 4 5) ---- -- running foo in the RequestMonad: -- --
-- runRequestMonad inputHandle outputHandle foo ---- -- will send both messages GetSumOf 1 2, GetSumOf 4 5, -- without having to wait for the repsonse to the first request. The last -- request GetSumOf 3 3 will be send after the response for the -- first message has arrived. module Sync.MerkleTree.Util.RequestMonad data RequestMonad b request :: (Serialize a, Serialize b) => a -> RequestMonad b -- | Run the provided request monad using the given communication channels runRequestMonad :: InputStream ByteString -> OutputStream ByteString -> RequestMonad b -> IO b -- | Combine results in the monad non-deterministically (it is required -- that the monoid is commutative) splitRequests :: Monoid a => [RequestMonad a] -> RequestMonad a instance Monad RequestMonad instance Functor RequestMonad instance Applicative RequestMonad instance MonadIO RequestMonad instance MonadIO (RequestMonadT ByteString) instance Monad (RequestMonadT ByteString) instance Applicative (RequestMonadT ByteString) instance Functor (RequestMonadT ByteString) module Sync.MerkleTree.Trie data Hash Hash :: ByteString -> Hash unHash :: Hash -> ByteString data Trie a Trie :: !Hash -> !(TrieNode a) -> Trie a t_hash :: Trie a -> !Hash t_node :: Trie a -> !(TrieNode a) data TrieNode a Node :: !(Array Int (Trie a)) -> TrieNode a Leave :: !(Set a) -> TrieNode a data NodeType NodeType :: NodeType LeaveType :: NodeType data TrieLocation TrieLocation :: Int -> Int -> TrieLocation -- | Must be nonnegative tl_level :: TrieLocation -> Int -- | Must be between nonnegative and smaller than (degree^tl_level) tl_index :: TrieLocation -> Int degree :: Int class HasDigest a digest :: HasDigest a => a -> Digest SHA256 -- | Fingerprint of a Merkle-Hash-Tree node We asssume the Tree below a -- node is identical while synchronizing if its FingerPrint is data Fingerprint Fingerprint :: Hash -> NodeType -> Fingerprint f_hash :: Fingerprint -> Hash f_nodeType :: Fingerprint -> NodeType toFingerprint :: Trie a -> Fingerprint -- | Creates a Merkle-Hash-Tree for a list of elements mkTrie :: (Ord a, HasDigest a) => Int -> [a] -> Trie a mkNode :: (Array Int (Trie a)) -> Trie a hashSHA256 :: ByteString -> Digest SHA256 combineHash :: [Hash] -> Hash -- | The function groupOf x eeturns a value between 0 to degree-1 -- for a digest with the property that groupOf forms an -- approximate unviversal hash familiy. groupOf :: HasDigest a => Int -> a -> Int mkLeave :: (HasDigest a, Ord a) => [a] -> Trie a lookup :: Monad m => Trie a -> TrieLocation -> m (Trie a) queryHash :: Monad m => Trie a -> TrieLocation -> m Fingerprint querySet :: (Ord a, Monad m) => Trie a -> TrieLocation -> m (Set a) getAll :: Ord a => Trie a -> Set a rootLocation :: TrieLocation expand :: TrieLocation -> (Array Int (Trie a)) -> [(TrieLocation, Trie a)] newtype TestDigest TestDigest :: Text -> TestDigest unTestDigest :: TestDigest -> Text tests :: Test instance Eq Hash instance Generic Hash instance Show a => Show (TrieNode a) instance Eq a => Eq (TrieNode a) instance Show a => Show (Trie a) instance Eq a => Eq (Trie a) instance Eq NodeType instance Generic NodeType instance Generic TrieLocation instance Eq Fingerprint instance Generic Fingerprint instance Eq TestDigest instance Ord TestDigest instance Show TestDigest instance Datatype D1Hash instance Constructor C1_0Hash instance Selector S1_0_0Hash instance Datatype D1NodeType instance Constructor C1_0NodeType instance Constructor C1_1NodeType instance Datatype D1TrieLocation instance Constructor C1_0TrieLocation instance Selector S1_0_0TrieLocation instance Selector S1_0_1TrieLocation instance Datatype D1Fingerprint instance Constructor C1_0Fingerprint instance Selector S1_0_0Fingerprint instance Selector S1_0_1Fingerprint instance HasDigest TestDigest instance Serialize Fingerprint instance Serialize TrieLocation instance Serialize NodeType instance Serialize Hash instance Show Hash module Sync.MerkleTree.Types -- | Information about a file that we expect to change, when the contents -- change. data File File :: Path -> FileSize -> FileModTime -> File f_name :: File -> Path f_size :: File -> FileSize f_modtime :: File -> FileModTime data Entry FileEntry :: File -> Entry DirectoryEntry :: Path -> Entry newtype FileSize FileSize :: Int64 -> FileSize unFileSize :: FileSize -> Int64 data FileModTime FileModTime :: !Int64 -> FileModTime unModTime :: FileModTime -> !Int64 -- | Representation for paths below the synchronization root directory data Path Root :: Path Path :: SerText -> Path -> Path -- | Returns the string representation of a path toFilePath :: FilePath -> Path -> FilePath -- | Entries are sorted first according to their depth in the path which is -- useful for directory operations -- | Return the depth of an entries path levelOf :: Entry -> Int data SerText SerText :: !Text -> SerText unSerText :: SerText -> !Text instance Eq FileSize instance Ord FileSize instance Generic FileSize instance Num FileSize instance Eq FileModTime instance Ord FileModTime instance Generic FileModTime instance Ord SerText instance Eq SerText instance Eq Path instance Ord Path instance Generic Path instance Eq File instance Ord File instance Generic File instance Eq Entry instance Generic Entry instance Datatype D1FileSize instance Constructor C1_0FileSize instance Selector S1_0_0FileSize instance Datatype D1FileModTime instance Constructor C1_0FileModTime instance Selector S1_0_0FileModTime instance Datatype D1Path instance Constructor C1_0Path instance Constructor C1_1Path instance Datatype D1File instance Constructor C1_0File instance Selector S1_0_0File instance Selector S1_0_1File instance Selector S1_0_2File instance Datatype D1Entry instance Constructor C1_0Entry instance Constructor C1_1Entry instance Serialize SerText instance HasDigest Entry instance Ord Entry instance Serialize Path instance Serialize FileModTime instance Serialize FileSize instance Serialize Entry instance Serialize File module Sync.MerkleTree.CommTypes class Monad m => Protocol m queryHashReq :: Protocol m => TrieLocation -> m Fingerprint querySetReq :: Protocol m => TrieLocation -> m (Set Entry) logReq :: Protocol m => SerText -> m Bool queryFileReq :: Protocol m => Path -> m QueryFileResponse queryFileContReq :: Protocol m => ContHandle -> m QueryFileResponse terminateReq :: Protocol m => m Bool data ContHandle ContHandle :: Int -> ContHandle data ClientServerOptions ClientServerOptions :: Bool -> Bool -> Bool -> [FilePath] -> ClientServerOptions cs_add :: ClientServerOptions -> Bool cs_update :: ClientServerOptions -> Bool cs_delete :: ClientServerOptions -> Bool cs_ignore :: ClientServerOptions -> [FilePath] data Request QuerySet :: TrieLocation -> Request QueryHash :: TrieLocation -> Request Log :: SerText -> Request QueryFile :: Path -> Request QueryFileCont :: ContHandle -> Request Terminate :: Request data QueryFileResponse Final :: QueryFileResponse ToBeContinued :: ByteString -> ContHandle -> QueryFileResponse data ProtocolVersion Version1 :: ProtocolVersion Version2 :: ProtocolVersion thisProtocolVersion :: ProtocolVersion data LaunchMessage LaunchMessage :: ProtocolVersion -> FilePath -> Side -> ClientServerOptions -> LaunchMessage lm_protocolVersion :: LaunchMessage -> ProtocolVersion lm_dir :: LaunchMessage -> FilePath lm_side :: LaunchMessage -> Side lm_clientServerOptions :: LaunchMessage -> ClientServerOptions data Side Server :: Side Client :: Side instance Generic ContHandle instance Read ClientServerOptions instance Show ClientServerOptions instance Generic Request instance Generic QueryFileResponse instance Read ProtocolVersion instance Show ProtocolVersion instance Eq ProtocolVersion instance Read Side instance Show Side instance Read LaunchMessage instance Show LaunchMessage instance Datatype D1ContHandle instance Constructor C1_0ContHandle instance Datatype D1Request instance Constructor C1_0Request instance Constructor C1_1Request instance Constructor C1_2Request instance Constructor C1_3Request instance Constructor C1_4Request instance Constructor C1_5Request instance Datatype D1QueryFileResponse instance Constructor C1_0QueryFileResponse instance Constructor C1_1QueryFileResponse instance Serialize QueryFileResponse instance Serialize Request instance Serialize ContHandle module Sync.MerkleTree.Client data Diff a Diff :: (Set a) -> (Set a) -> Diff a showText :: Show a => a -> Text dataSize :: Foldable f => f Entry -> FileSize dataSizeText :: Foldable f => f Entry -> Text class (Protocol m, MonadIO m) => ClientMonad m split :: (ClientMonad m, Monoid a) => [m a] -> m a logClient :: Protocol m => Text -> m () data SimpleEntry FileSimpleEntry :: Path -> SimpleEntry DirectorySimpleEntry :: Path -> SimpleEntry analyseEntries :: Diff Entry -> ([Entry], [Entry], [Entry]) data Progress Progress :: IORef FileSize -> IORef Int -> IORef UTCTime -> Progress pg_size :: Progress -> IORef FileSize pg_count :: Progress -> IORef Int pg_last :: Progress -> IORef UTCTime abstractClient :: ClientMonad m => ClientServerOptions -> FilePath -> Trie Entry -> m () _CONCURRENT_FILETRANSFER_SIZE_ :: Int splitEvery :: Int -> [a] -> [[a]] syncNewOrChangedEntries :: ClientMonad m => Progress -> FilePath -> [Entry] -> m () showProgess :: ClientMonad m => Progress -> m () synchronizeNewOrChangedEntry :: ClientMonad m => Progress -> FilePath -> Entry -> m () nodeReq :: ClientMonad m => (TrieLocation, Trie Entry) -> m (Diff Entry) testEntry :: Test instance Eq SimpleEntry instance Ord SimpleEntry instance Ord a => Monoid (Diff a) module Sync.MerkleTree.Server data ServerState ServerState :: Map Int Handle -> Int -> Trie Entry -> FilePath -> ServerState -- | Map of open file handles with their ids st_handles :: ServerState -> Map Int Handle -- | Next available id st_nextHandle :: ServerState -> Int -- | Merkle Hash Tree of server file hierarchy st_trie :: ServerState -> Trie Entry -- | path of the root of the file hierarchy st_path :: ServerState -> FilePath type ServerMonad = StateT ServerState IO startServerState :: FilePath -> Trie Entry -> IO ServerState -- | Respond to a queryFile or queryFileCont request for a given file -- handle and id withHandle :: Handle -> Int -> ServerMonad QueryFileResponse instance Protocol ServerMonad module Sync.MerkleTree.Analyse -- | Returns all files and directories below the given FilePath analyse :: FilePath -> [String] -> IO [Entry] -- | Returns True if the given string is not "." or ".." isRealFile :: String -> Bool module Sync.MerkleTree.Sync child :: StreamPair -> IO () local :: ClientServerOptions -> FilePath -> FilePath -> IO () parent :: StreamPair -> FilePath -> FilePath -> Direction -> ClientServerOptions -> IO () openStreams :: Handle -> Handle -> IO StreamPair mkChanStreams :: IO (InputStream ByteString, OutputStream ByteString) data StreamPair StreamPair :: InputStream ByteString -> OutputStream ByteString -> StreamPair sp_in :: StreamPair -> InputStream ByteString sp_out :: StreamPair -> OutputStream ByteString data Direction FromRemote :: Direction ToRemote :: Direction tests :: Test instance ClientMonad ServerMonad instance ClientMonad RequestMonad instance Protocol RequestMonad module Sync.MerkleTree.Run data RemoteCmd RemoteCmd :: String -> RemoteCmd Simulate :: RemoteCmd data SyncOptions SyncOptions :: Maybe FilePath -> Maybe FilePath -> Maybe RemoteCmd -> [String] -> [FilePath] -> Bool -> Bool -> Bool -> Bool -> [String] -> SyncOptions so_source :: SyncOptions -> Maybe FilePath so_destination :: SyncOptions -> Maybe FilePath so_remote :: SyncOptions -> Maybe RemoteCmd so_ignore :: SyncOptions -> [String] so_boring :: SyncOptions -> [FilePath] so_add :: SyncOptions -> Bool so_update :: SyncOptions -> Bool so_delete :: SyncOptions -> Bool so_help :: SyncOptions -> Bool so_nonOptions :: SyncOptions -> [String] defaultSyncOptions :: SyncOptions toClientServerOptions :: SyncOptions -> IO ClientServerOptions optDescriptions :: [OptDescr (SyncOptions -> SyncOptions)] parseNonOption :: String -> (SyncOptions -> SyncOptions) toSyncOptions :: [(SyncOptions -> SyncOptions)] -> SyncOptions putError :: String -> IO () _HIDDENT_CLIENT_MODE_OPTION_ :: String printUsageInfo :: String -> [String] -> IO () data Location Remote :: FilePath -> Location Local :: FilePath -> Location parseFilePath :: FilePath -> Location main :: String -> [String] -> IO () run :: String -> SyncOptions -> IO () runChild :: IO () runParent :: ClientServerOptions -> RemoteCmd -> FilePath -> FilePath -> Direction -> IO ()