diff --git a/Hash2Pub/FediChord.asn1 b/Hash2Pub/FediChord.asn1 index 643c0ce..bf9ebff 100644 --- a/Hash2Pub/FediChord.asn1 +++ b/Hash2Pub/FediChord.asn1 @@ -2,12 +2,88 @@ FediChordProtocol DEFINITIONS AUTOMATIC TAGS ::= BEGIN NodeID ::= INTEGER (0..115792089237316195423570985008687907853269984665640564039457584007913129639935) +Domain ::= VisibleString + Request ::= SEQUENCE { requestID INTEGER, senderID NodeID, - parts INTEGER, - part INTEGER, - action ENUMERATED {queryID, join, leave, stabilise} + parts INTEGER, -- number of message parts + part INTEGER, -- part number of this message + action ENUMERATED {queryID, join, leave, stabilise, ping}, + actionPayload CHOICE { + queryIDSendPayload QueryIDSendPayload, + joinSendPayload JoinSendPayload, + leaveSendPayload LeaveSendPayload, + stabiliseSendPayload StabiliseSendPayload + } } +Response ::= SEQUENCE { + responseTo INTEGER, + senderID NodeID, + parts INTEGER, + part INTEGER, + action ENUMERATED {queryID, join, leave, stabilise, ping}, + actionPayload CHOICE { + queryIDReceivePayload QueryIDReceivePayload, + joinReceivePayload JoinReceivePayload, + leaveReceivePayload LeaveReceivePayload, + stabiliseReceivePayload StabiliseReceivePayload + } + } + +NodeState ::= SEQUENCE { + nid NodeID, + domain Domain, + ipAddr OCTET STRING (SIZE(16)), + dhtPort INTEGER, + apPort INTEGER, + vServer INTEGER + } + +CacheEntry ::= SEQUENCE { + node NodeState, + -- use unix time stamp, as DATE-TIME isn't supported by the Haskell lib + timestamp INTEGER + } + +NodeCache ::= SEQUENCE OF CacheEntry + +JoinSendPayload ::= NodeState + +JoinReceivePayload ::= SEQUENCE { + successors SEQUENCE OF NodeID, + predecessors SEQUENCE OF NodeID, + cache NodeCache + } + +QueryIDSendPayload ::= SEQUENCE { + targetID NodeID, + lBestNodes INTEGER + } + +QueryResult ::= ENUMERATED { found, forward } + +QueryIDReceivePayload ::= SEQUENCE { + result QueryResult, + nodeData NodeCache + } + +StabiliseSendPayload ::= NodeState + +StabiliseReceivePayload ::= SEQUENCE { + successors SEQUENCE OF NodeID, + predecessors SEQUENCE OF NodeID + -- ToDo: transfer of handled key data, if newly responsible for it + } + +LeaveSendPayload ::= SEQUENCE { + successors SEQUENCE OF NodeID, + predecessors SEQUENCE OF NodeID + -- ToDo: transfer of own data to newly responsible node + } + +LeaveReceivePayload ::= NULL -- just a confirmation + + END diff --git a/Hash2Pub/src/Hash2Pub/FediChord.hs b/Hash2Pub/src/Hash2Pub/FediChord.hs index 91f26ac..f449816 100644 --- a/Hash2Pub/src/Hash2Pub/FediChord.hs +++ b/Hash2Pub/src/Hash2Pub/FediChord.hs @@ -111,6 +111,8 @@ data NodeState = NodeState { , apPort :: Maybe PortNumber -- ^ port of the ActivityPub relay and storage service -- might have to be queried first + + -- ==== internal state ==== , nodeCache :: NodeCache -- ^ EpiChord node cache with expiry times for nodes -- as the map is ordered, lookups for the closes preceding node can be done using @lookupLT@ diff --git a/Hash2Pub/src/asn1test.hs b/Hash2Pub/src/asn1test.hs index cd8fef1..7146d9c 100644 --- a/Hash2Pub/src/asn1test.hs +++ b/Hash2Pub/src/asn1test.hs @@ -37,12 +37,6 @@ testParser = do getAll :: ASN1P.ParseASN1 [ASN1.ASN1] getAll = ASN1P.getMany ASN1P.getNext --- | run a function of the next elements of a container of specified type -onNextContainer' :: ASN1.ASN1ConstructionType -> ASN1P.ParseASN1 a -> ASN1P.ParseASN1 a -onNextContainer' ty f = do - cont <- ASN1P.getNextContainer ty - either ASN1P.throwParseError return . trace (show cont) $ ASN1P.runParseASN1 f cont - --stringParser asn1obj = -- fmap (fromMaybe "" $ ASN1.asn1CharacterToString) ASN1P.getNext