mirror of https://github.com/voidlizard/hbs2
very basic acls work
This commit is contained in:
parent
51d03f2265
commit
781c9ded4b
|
@ -224,8 +224,7 @@ refChanUpdateProto self adapter msg = do
|
||||||
|
|
||||||
void $ runMaybeT do
|
void $ runMaybeT do
|
||||||
|
|
||||||
guard auth
|
guard (auth || self)
|
||||||
|
|
||||||
|
|
||||||
case msg of
|
case msg of
|
||||||
Propose chan box -> do
|
Propose chan box -> do
|
||||||
|
@ -259,7 +258,10 @@ refChanUpdateProto self adapter msg = do
|
||||||
deferred proto do
|
deferred proto do
|
||||||
|
|
||||||
-- проверили подпись пира
|
-- проверили подпись пира
|
||||||
(peerKey, (ProposeTran headRef bs)) <- MaybeT $ pure $ unboxSignedBox0 box
|
(peerKey, ProposeTran headRef abox) <- MaybeT $ pure $ unboxSignedBox0 box
|
||||||
|
|
||||||
|
-- проверили подпись автора
|
||||||
|
(authorKey, bs) <- MaybeT $ pure $ unboxSignedBox0 abox
|
||||||
|
|
||||||
-- итак, сначала достаём голову. как мы достаём голову?
|
-- итак, сначала достаём голову. как мы достаём голову?
|
||||||
h <- MaybeT $ liftIO $ getRef sto (RefChanHeadKey @s chan)
|
h <- MaybeT $ liftIO $ getRef sto (RefChanHeadKey @s chan)
|
||||||
|
@ -274,7 +276,18 @@ refChanUpdateProto self adapter msg = do
|
||||||
-- FIXME: cache-this
|
-- FIXME: cache-this
|
||||||
hdblob <- MaybeT $ readBlobFromTree ( getBlock sto ) (HashRef h)
|
hdblob <- MaybeT $ readBlobFromTree ( getBlock sto ) (HashRef h)
|
||||||
|
|
||||||
debug "OMG! OMG! We've got a transaction!!"
|
(_, headBlock) <- MaybeT $ pure $ unboxSignedBox @(RefChanHeadBlock e) @e hdblob
|
||||||
|
|
||||||
|
debug $ "OMG! Got trans" <+> pretty (AsBase58 peerKey) <+> pretty (AsBase58 authorKey)
|
||||||
|
|
||||||
|
let pips = view refChanHeadPeers headBlock & fmap fst
|
||||||
|
let aus = view refChanHeadAuthors headBlock
|
||||||
|
|
||||||
|
guard ( peerKey `elem` pips )
|
||||||
|
|
||||||
|
guard ( authorKey `elem` aus )
|
||||||
|
|
||||||
|
debug $ "OMG!!! TRANS AUTHORIZED" <+> pretty (AsBase58 peerKey) <+> pretty (AsBase58 authorKey)
|
||||||
|
|
||||||
pure ()
|
pure ()
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ pRefChanPropose = do
|
||||||
|
|
||||||
lbs <- maybe1 fn LBS.getContents LBS.readFile
|
lbs <- maybe1 fn LBS.getContents LBS.readFile
|
||||||
|
|
||||||
let box = makeSignedBox @L4Proto @ByteString (view peerSignPk creds) (view peerSignSk creds) lbs
|
let box = makeSignedBox @L4Proto @BS.ByteString (view peerSignPk creds) (view peerSignSk creds) (LBS.toStrict lbs)
|
||||||
|
|
||||||
if dry then do
|
if dry then do
|
||||||
LBS.putStr (serialise box)
|
LBS.putStr (serialise box)
|
||||||
|
|
|
@ -963,8 +963,7 @@ runPeer opts = U.handle (\e -> myException e
|
||||||
let reflogFetchAction puk = do
|
let reflogFetchAction puk = do
|
||||||
trace "reflogFetchAction"
|
trace "reflogFetchAction"
|
||||||
void $ liftIO $ async $ withPeerM penv $ do
|
void $ liftIO $ async $ withPeerM penv $ do
|
||||||
forKnownPeers @e $ \p _ -> do
|
broadCastMessage (RefLogRequest @e puk)
|
||||||
request p (RefLogRequest @e puk)
|
|
||||||
|
|
||||||
let reflogGetAction puk = do
|
let reflogGetAction puk = do
|
||||||
trace $ "reflogGetAction" <+> pretty (AsBase58 puk)
|
trace $ "reflogGetAction" <+> pretty (AsBase58 puk)
|
||||||
|
@ -1011,10 +1010,18 @@ runPeer opts = U.handle (\e -> myException e
|
||||||
let refChanProposeAction (puk, lbs) = do
|
let refChanProposeAction (puk, lbs) = do
|
||||||
trace "reChanProposeAction"
|
trace "reChanProposeAction"
|
||||||
void $ liftIO $ async $ withPeerM penv $ do
|
void $ liftIO $ async $ withPeerM penv $ do
|
||||||
let mbox = deserialiseOrFail lbs & either (const Nothing) Just
|
me <- ownPeer @e
|
||||||
maybe1 mbox (err "proposal: Can't read SignedBox") $ \box -> do
|
runMaybeT do
|
||||||
proposed <- makeProposeTran @e pc puk box
|
box <- MaybeT $ pure $ deserialiseOrFail lbs & either (const Nothing) Just
|
||||||
|
proposed <- MaybeT $ makeProposeTran @e pc puk box
|
||||||
|
|
||||||
debug $ "PROPOSAL:" <+> pretty (LBS.length (serialise proposed))
|
debug $ "PROPOSAL:" <+> pretty (LBS.length (serialise proposed))
|
||||||
|
lift $ broadCastMessage (Propose @e puk proposed)
|
||||||
|
|
||||||
|
-- FIXME: remove-this-debug-stuff
|
||||||
|
-- или оставить? нода будет сама себе
|
||||||
|
-- консенсус слать тогда. может, и оставить
|
||||||
|
lift $ runResponseM me $ refChanUpdateProto @e True refChanHeadAdapter (Propose @e puk proposed)
|
||||||
|
|
||||||
let arpc = RpcAdapter pokeAction
|
let arpc = RpcAdapter pokeAction
|
||||||
dieAction
|
dieAction
|
||||||
|
|
Loading…
Reference in New Issue