-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inital poke implementation #1037
Conversation
@@ -173,7 +183,17 @@ proc getBlock*( | |||
|
|||
# content is in range and valid, put into db | |||
if h.portalProtocol.inRange(contentId): | |||
h.contentDB.put(contentId, bodyContent) | |||
# TODO this bit is quite troubling, currently we may trigger offer/accept |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning on putting the poke in the contentLookup
proc just before it returns the content (with an asyncSpawn
). I assume that you had the same in mind, but solved it like this for now because of the offer
call using the database, hence the "quit troubling` wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, I have also initially planning to add it in contentLookup, but having it here is the only way to make sure that:
a) Content is really in database, before triggering poke
b) Content is really validated before spreading it around
## offer directly to avoid potential problems when content is not really in database | ||
## this will be especially important when we introduce deleting content | ||
## from database | ||
let keys = List[ByteList, contentKeysLimit].init(@[contentKey]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to do ContentKeysList.init()
directly iirc
else: | ||
# TODO: Should we do something with the node that failed responding our | ||
# query? | ||
discard | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace
# which means we cannot propagate content which is not in our range, but maybe | ||
# in range of other nodes. | ||
h.contentDB.put(contentId, headerContent.content) | ||
# content is valid and in db we may propagate it through the network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# content is valid and in db we may propagate it through the network | |
# content is valid and in the db, it may be propagated it through the network |
@@ -144,12 +144,28 @@ type | |||
Content | |||
|
|||
FoundContent* = object | |||
dst*: Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dst*: Node | |
src*: Node |
it is kind of the src
node with respect to the found content
@@ -168,9 +184,16 @@ func localNode*(p: PortalProtocol): Node = p.baseProtocol.localNode | |||
func neighbours*(p: PortalProtocol, id: NodeId, seenOnly = false): seq[Node] = | |||
p.routingTable.neighbours(id = id, seenOnly = seenOnly) | |||
|
|||
proc inRangeImpl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just be called inRange
as it will be a directly useful proc also, and it shouldn't give naming symbol issues considering it has different parameter list.
nodes: seq[Node], | ||
contentKey: ByteList, | ||
contentId: ContentId) = | ||
## Trigers asynchronous offer-accept interaction to provided nodes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Trigers asynchronous offer-accept interaction to provided nodes. | |
## Triggers asynchronous offer-accept interaction to provided nodes. |
# we only return nodes which may be interested in content | ||
# also we do not need to chec for duplicates in nodesWithoutContent | ||
# as we never make requests two times to the same node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# we only return nodes which may be interested in content | |
# also we do not need to chec for duplicates in nodesWithoutContent | |
# as we never make requests two times to the same node | |
# Only return nodes which may be interested in content. | |
# No need to checc for duplicates in nodesWithoutContent | |
# as requests are never made two times to the same node. |
Initial implementation of POKE mechanism i.e offering content to nodes which we discovered do not have it during content lookup.
One caveat for now:
todo
in offer procedure which would fix it i.e passing content directly ofoffer
procedure, instead of using db as communication channel. It would also cause problem when we add deleting stuff from db, as offer-accept is asynchronous so the content could be deleted before be send it via uTP.