RefLogKey moved to HBS2.Net.Proto.RefLog...

... since it is just one of many possible refs
This commit is contained in:
Dmitry Zuikov 2023-08-10 05:50:39 +03:00
parent 7274c6ceeb
commit 40ba5fca68
5 changed files with 30 additions and 33 deletions

View File

@ -141,27 +141,4 @@ type IsRefPubKey s = ( Eq (PubKey 'Sign s)
, Hashable (PubKey 'Sign s) , Hashable (PubKey 'Sign s)
) )
newtype RefLogKey s = RefLogKey (PubKey 'Sign s)
deriving stock instance IsRefPubKey s => Eq (RefLogKey s)
instance IsRefPubKey s => Hashable (RefLogKey s) where
hashWithSalt s k = hashWithSalt s (hashObject @HbSync k)
instance IsRefPubKey s => Hashed HbSync (RefLogKey s) where
hashObject (RefLogKey pk) = hashObject ("reflogkey|" <> serialise pk)
instance IsRefPubKey s => FromStringMaybe (RefLogKey s) where
fromStringMay s = RefLogKey <$> fromStringMay s
instance IsRefPubKey s => IsString (RefLogKey s) where
fromString s = fromMaybe (error "bad public key base58") (fromStringMay s)
instance Pretty (AsBase58 (PubKey 'Sign s )) => Pretty (AsBase58 (RefLogKey s)) where
pretty (AsBase58 (RefLogKey k)) = pretty (AsBase58 k)
instance Pretty (AsBase58 (PubKey 'Sign s )) => Pretty (RefLogKey s) where
pretty (RefLogKey k) = pretty (AsBase58 k)

View File

@ -17,11 +17,35 @@ import HBS2.Data.Types.Refs
import HBS2.System.Logger.Simple import HBS2.System.Logger.Simple
import Data.Maybe import Data.Maybe
import Data.Hashable import Data.Hashable hiding (Hashed)
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import Type.Reflection (someTypeRep) import Type.Reflection (someTypeRep)
import Lens.Micro.Platform import Lens.Micro.Platform
newtype RefLogKey s = RefLogKey (PubKey 'Sign s)
deriving stock instance IsRefPubKey s => Eq (RefLogKey s)
instance IsRefPubKey s => Hashable (RefLogKey s) where
hashWithSalt s k = hashWithSalt s (hashObject @HbSync k)
instance IsRefPubKey s => Hashed HbSync (RefLogKey s) where
hashObject (RefLogKey pk) = hashObject ("reflogkey|" <> serialise pk)
instance IsRefPubKey s => FromStringMaybe (RefLogKey s) where
fromStringMay s = RefLogKey <$> fromStringMay s
instance IsRefPubKey s => IsString (RefLogKey s) where
fromString s = fromMaybe (error "bad public key base58") (fromStringMay s)
instance Pretty (AsBase58 (PubKey 'Sign s )) => Pretty (AsBase58 (RefLogKey s)) where
pretty (AsBase58 (RefLogKey k)) = pretty (AsBase58 k)
instance Pretty (AsBase58 (PubKey 'Sign s )) => Pretty (RefLogKey s) where
pretty (RefLogKey k) = pretty (AsBase58 k)
data RefLogRequest e = data RefLogRequest e =
RefLogRequest (PubKey 'Sign (Encryption e)) RefLogRequest (PubKey 'Sign (Encryption e))
| RefLogResponse (PubKey 'Sign (Encryption e)) (Hash HbSync) | RefLogResponse (PubKey 'Sign (Encryption e)) (Hash HbSync)

View File

@ -10,8 +10,7 @@ module HBS2Git.Types
import HBS2.Prelude.Plated import HBS2.Prelude.Plated
import HBS2.Git.Types import HBS2.Git.Types
import HBS2.Net.Proto.Types(L4Proto) import HBS2.Net.Proto.RefLog (RefLogKey(..))
import HBS2.Data.Types.Refs
import HBS2.Net.Proto.Types import HBS2.Net.Proto.Types
import HBS2.Net.Auth.Credentials import HBS2.Net.Auth.Credentials
@ -27,17 +26,13 @@ import Control.Monad.IO.Class
import Control.Monad.Reader import Control.Monad.Reader
import Database.SQLite.Simple (Connection) import Database.SQLite.Simple (Connection)
import Data.Char (isSpace) import Data.Char (isSpace)
import Data.Set qualified as Set
import Data.Set (Set)
import Data.List qualified as List import Data.List qualified as List
import Data.Maybe
import Lens.Micro.Platform import Lens.Micro.Platform
import Data.HashMap.Strict (HashMap) import Data.HashMap.Strict (HashMap)
import Data.HashMap.Strict qualified as HashMap import Data.HashMap.Strict qualified as HashMap
import Codec.Serialise import Codec.Serialise
import Control.Concurrent.STM import Control.Concurrent.STM
import System.IO qualified as IO import System.IO qualified as IO
import UnliftIO.IO qualified as UIO
import System.IO (Handle) import System.IO (Handle)
import Data.Kind import Data.Kind
import Control.Monad.Catch import Control.Monad.Catch

View File

@ -2,12 +2,12 @@
module PeerMain.DialogCliCommand where module PeerMain.DialogCliCommand where
import Data.Generics.Labels -- import Data.Generics.Labels
import Data.Generics.Product.Fields -- import Data.Generics.Product.Fields
import HBS2.Actors.Peer import HBS2.Actors.Peer
import HBS2.Base58 import HBS2.Base58
import HBS2.Clock import HBS2.Clock
import HBS2.Data.Types.Refs (RefLogKey(..)) import HBS2.Net.Proto.RefLog (RefLogKey(..))
import HBS2.Defaults import HBS2.Defaults
import HBS2.Events import HBS2.Events
import HBS2.Hash import HBS2.Hash

View File

@ -9,6 +9,7 @@ import HBS2.Net.Proto.Types
import HBS2.Net.Auth.AccessKey import HBS2.Net.Auth.AccessKey
import HBS2.Net.Auth.Credentials import HBS2.Net.Auth.Credentials
import HBS2.Net.Proto.Definition() import HBS2.Net.Proto.Definition()
import HBS2.Net.Proto.RefLog(RefLogKey(..))
import HBS2.Prelude.Plated import HBS2.Prelude.Plated
import HBS2.Storage.Simple import HBS2.Storage.Simple
import HBS2.Storage.Simple.Extra import HBS2.Storage.Simple.Extra