mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
57fb0516f1
commit
bdd98632b4
|
@ -141,10 +141,11 @@ walkRefChanTx :: forall proto m . ( MonadIO m
|
||||||
, HasProtocol proto (ServiceProto RefChanAPI proto)
|
, HasProtocol proto (ServiceProto RefChanAPI proto)
|
||||||
, HasStorage m
|
, HasStorage m
|
||||||
)
|
)
|
||||||
=> PubKey 'Sign 'HBS2Basic
|
=> (HashRef -> m Bool)
|
||||||
-> (RefChanUpdateUnpacked L4Proto -> m ())
|
-> PubKey 'Sign 'HBS2Basic
|
||||||
|
-> (HashRef -> RefChanUpdateUnpacked L4Proto -> m ())
|
||||||
-> m ()
|
-> m ()
|
||||||
walkRefChanTx puk action = do
|
walkRefChanTx filt puk action = do
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
api <- getClientAPI @RefChanAPI @proto
|
api <- getClientAPI @RefChanAPI @proto
|
||||||
|
|
||||||
|
@ -162,21 +163,23 @@ walkRefChanTx puk action = do
|
||||||
|
|
||||||
Right (hs :: [HashRef]) -> do
|
Right (hs :: [HashRef]) -> do
|
||||||
for_ hs $ \h -> do
|
for_ hs $ \h -> do
|
||||||
lbs' <- getBlock sto (coerce h)
|
want <- lift (filt h)
|
||||||
lbs <- ContT $ maybe1 lbs' none
|
when want do
|
||||||
|
lbs' <- getBlock sto (coerce h)
|
||||||
|
lbs <- ContT $ maybe1 lbs' none
|
||||||
|
|
||||||
let txraw = deserialiseOrFail @(RefChanUpdate L4Proto) lbs
|
let txraw = deserialiseOrFail @(RefChanUpdate L4Proto) lbs
|
||||||
& either (const Nothing) Just
|
& either (const Nothing) Just
|
||||||
|
|
||||||
tx <- ContT $ maybe1 txraw none
|
tx <- ContT $ maybe1 txraw none
|
||||||
|
|
||||||
case tx of
|
case tx of
|
||||||
|
|
||||||
Accept _ box -> do
|
Accept _ box -> do
|
||||||
(_, txx) <- ContT $ maybe1 (unboxSignedBox0 box) none
|
(_, txx) <- ContT $ maybe1 (unboxSignedBox0 box) none
|
||||||
lift $ action (A txx)
|
lift $ action h (A txx)
|
||||||
|
|
||||||
Propose _ box -> do
|
Propose _ box -> do
|
||||||
(_, txx) <- ContT $ maybe1 (unboxSignedBox0 box) none
|
(_, txx) <- ContT $ maybe1 (unboxSignedBox0 box) none
|
||||||
lift $ action (P h txx)
|
lift $ action h (P h txx)
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,8 @@ getStateFromRefChan rchan = do
|
||||||
outq <- newTQueueIO
|
outq <- newTQueueIO
|
||||||
tss <- newTVarIO mempty
|
tss <- newTVarIO mempty
|
||||||
|
|
||||||
walkRefChanTx @UNIX rchan $ \case
|
-- FIXME: may-be-slow
|
||||||
|
walkRefChanTx @UNIX (const $ pure True) rchan $ \txh -> \case
|
||||||
A (AcceptTran ts _ what) -> do
|
A (AcceptTran ts _ what) -> do
|
||||||
-- debug $ red "ACCEPT" <+> pretty ts <+> pretty what
|
-- debug $ red "ACCEPT" <+> pretty ts <+> pretty what
|
||||||
for_ ts $ \w -> do
|
for_ ts $ \w -> do
|
||||||
|
|
Loading…
Reference in New Issue