diff --git a/hbs2-peer/app/RPC2/LWWRef.hs b/hbs2-peer/app/RPC2/LWWRef.hs new file mode 100644 index 00000000..41a8b6dc --- /dev/null +++ b/hbs2-peer/app/RPC2/LWWRef.hs @@ -0,0 +1 @@ +module RPC2.LWWRef where \ No newline at end of file diff --git a/hbs2-peer/hbs2-peer.cabal b/hbs2-peer/hbs2-peer.cabal index 6ab7c20d..47cc753c 100644 --- a/hbs2-peer/hbs2-peer.cabal +++ b/hbs2-peer/hbs2-peer.cabal @@ -164,6 +164,7 @@ library HBS2.Peer.RPC.API.Peer HBS2.Peer.RPC.API.RefLog HBS2.Peer.RPC.API.RefChan + HBS2.Peer.RPC.API.LWWRef HBS2.Peer.RPC.API.Storage HBS2.Peer.RPC.Client.Unix HBS2.Peer.RPC.Client.StorageClient @@ -257,6 +258,7 @@ executable hbs2-peer , RPC2.Downloads , RPC2.RefLog , RPC2.RefChan + , RPC2.LWWRef , PeerTypes , PeerLogger , PeerConfig diff --git a/hbs2-peer/lib/HBS2/Peer/RPC/API/LWWRef.hs b/hbs2-peer/lib/HBS2/Peer/RPC/API/LWWRef.hs new file mode 100644 index 00000000..267a9007 --- /dev/null +++ b/hbs2-peer/lib/HBS2/Peer/RPC/API/LWWRef.hs @@ -0,0 +1,35 @@ +module HBS2.Peer.RPC.API.LWWRef where + +import HBS2.Peer.Prelude +import HBS2.Peer.Proto.LWWRef +import HBS2.Data.Types.SignedBox +import HBS2.Net.Messaging.Unix +import HBS2.Data.Types.Refs (HashRef(..)) +import HBS2.Net.Proto.Service +import HBS2.Peer.Proto.RefLog (RefLogUpdate) + +import Data.ByteString.Lazy (ByteString) +import Codec.Serialise + +data LWWRefGet +data LWWRefUpdate + +type LWWRefAPI = '[ LWWRefGet -- may be done via storage + , LWWRefUpdate -- + ] + + +instance HasProtocol UNIX (ServiceProto LWWRefAPI UNIX) where + type instance ProtocolId (ServiceProto LWWRefAPI UNIX) = 16267229472009458342 + type instance Encoded UNIX = ByteString + decode = either (const Nothing) Just . deserialiseOrFail + encode = serialise + +type instance Input LWWRefGet = LWWRefKey HBS2Basic +type instance Output LWWRefGet = Maybe (LWWRef L4Proto) + +type instance Input LWWRefUpdate = SignedBox (LWWRef L4Proto) L4Proto +type instance Output LWWRefUpdate = () + + +