mirror of https://github.com/voidlizard/hbs2
wip, parse notifiers section
This commit is contained in:
parent
a294f19aa3
commit
147db0552f
|
@ -228,21 +228,16 @@ instance Pretty (AsBase58 (PubKey 'Sign s )) => Pretty (RefChanLogKey s) where
|
||||||
|
|
||||||
instance ForRefChans e => FromStringMaybe (RefChanHeadBlock e) where
|
instance ForRefChans e => FromStringMaybe (RefChanHeadBlock e) where
|
||||||
|
|
||||||
|
-- NOTE: we-dont-support-old-head-formats-anymore
|
||||||
fromStringMay str =
|
fromStringMay str =
|
||||||
case readers of
|
RefChanHeadBlock2 <$> version
|
||||||
[] -> RefChanHeadBlockSmall <$> version
|
<*> quorum
|
||||||
<*> quorum
|
<*> wait
|
||||||
<*> wait
|
<*> pure (HashMap.fromList peers)
|
||||||
<*> pure (HashMap.fromList peers)
|
<*> pure (HashSet.fromList authors)
|
||||||
<*> pure (HashSet.fromList authors)
|
<*> pure (HashSet.fromList readers)
|
||||||
|
<*> pure (HashSet.fromList notifiers)
|
||||||
rs -> RefChanHeadBlock1 <$> version
|
<*> pure mempty
|
||||||
<*> quorum
|
|
||||||
<*> wait
|
|
||||||
<*> pure (HashMap.fromList peers)
|
|
||||||
<*> pure (HashSet.fromList authors)
|
|
||||||
<*> pure (HashSet.fromList rs)
|
|
||||||
<*> pure mempty
|
|
||||||
|
|
||||||
where
|
where
|
||||||
parsed = parseTop str & fromRight mempty
|
parsed = parseTop str & fromRight mempty
|
||||||
|
@ -262,6 +257,11 @@ instance ForRefChans e => FromStringMaybe (RefChanHeadBlock e) where
|
||||||
| (ListVal [SymbolVal "reader", LitStrVal s] ) <- parsed
|
| (ListVal [SymbolVal "reader", LitStrVal s] ) <- parsed
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
notifiers = catMaybes [ fromStringMay @(PubKey 'Sign (Encryption e)) (Text.unpack s)
|
||||||
|
| (ListVal [SymbolVal "notifier", LitStrVal s] ) <- parsed
|
||||||
|
]
|
||||||
|
|
||||||
instance (ForRefChans e
|
instance (ForRefChans e
|
||||||
, Pretty (AsBase58 (PubKey 'Sign (Encryption e)))
|
, Pretty (AsBase58 (PubKey 'Sign (Encryption e)))
|
||||||
, Pretty (AsBase58 (PubKey 'Encrypt (Encryption e)))
|
, Pretty (AsBase58 (PubKey 'Encrypt (Encryption e)))
|
||||||
|
@ -277,11 +277,14 @@ instance (ForRefChans e
|
||||||
vcat (fmap author (HashSet.toList $ view refChanHeadAuthors blk)) <> line
|
vcat (fmap author (HashSet.toList $ view refChanHeadAuthors blk)) <> line
|
||||||
<>
|
<>
|
||||||
vcat (fmap reader (HashSet.toList $ view refChanHeadReaders blk)) <> line
|
vcat (fmap reader (HashSet.toList $ view refChanHeadReaders blk)) <> line
|
||||||
|
<>
|
||||||
|
vcat (fmap notifier (HashSet.toList $ view refChanHeadNotifiers blk)) <> line
|
||||||
|
|
||||||
where
|
where
|
||||||
peer (p,w) = parens ("peer" <+> dquotes (pretty (AsBase58 p)) <+> pretty w)
|
peer (p,w) = parens ("peer" <+> dquotes (pretty (AsBase58 p)) <+> pretty w)
|
||||||
author p = parens ("author" <+> dquotes (pretty (AsBase58 p)))
|
author p = parens ("author" <+> dquotes (pretty (AsBase58 p)))
|
||||||
reader p = parens ("reader" <+> dquotes (pretty (AsBase58 p)))
|
reader p = parens ("reader" <+> dquotes (pretty (AsBase58 p)))
|
||||||
|
notifier p = parens ("notifier" <+> dquotes (pretty (AsBase58 p)))
|
||||||
|
|
||||||
|
|
||||||
-- блок головы может быть довольно большой.
|
-- блок головы может быть довольно большой.
|
||||||
|
|
Loading…
Reference in New Issue