forked from schmittlauch/Hash2Pub
ASN.1 module schema specification for DHT protocol
This commit is contained in:
parent
e1228da74d
commit
24936d48c1
|
@ -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
|
||||
|
|
|
@ -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@
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue