koi-net 1.0.0b14__tar.gz → 1.0.0b15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of koi-net might be problematic. Click here for more details.

Files changed (32) hide show
  1. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/PKG-INFO +1 -1
  2. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/pyproject.toml +1 -1
  3. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/processor/default_handlers.py +53 -0
  4. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/.github/workflows/publish-to-pypi.yml +0 -0
  5. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/.gitignore +0 -0
  6. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/LICENSE +0 -0
  7. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/README.md +0 -0
  8. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/examples/basic_coordinator_node.py +0 -0
  9. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/examples/basic_partial_node.py +0 -0
  10. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/examples/full_node_template.py +0 -0
  11. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/examples/partial_node_template.py +0 -0
  12. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/requirements.txt +0 -0
  13. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/__init__.py +0 -0
  14. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/config.py +0 -0
  15. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/core.py +0 -0
  16. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/identity.py +0 -0
  17. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/network/__init__.py +0 -0
  18. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/network/graph.py +0 -0
  19. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/network/interface.py +0 -0
  20. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/network/request_handler.py +0 -0
  21. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/network/response_handler.py +0 -0
  22. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/processor/__init__.py +0 -0
  23. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/processor/handler.py +0 -0
  24. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/processor/interface.py +0 -0
  25. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/processor/knowledge_object.py +0 -0
  26. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/__init__.py +0 -0
  27. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/api_models.py +0 -0
  28. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/consts.py +0 -0
  29. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/edge.py +0 -0
  30. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/event.py +0 -0
  31. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/helpers.py +0 -0
  32. {koi_net-1.0.0b14 → koi_net-1.0.0b15}/src/koi_net/protocol/node.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koi-net
3
- Version: 1.0.0b14
3
+ Version: 1.0.0b15
4
4
  Summary: Implementation of KOI-net protocol in Python
5
5
  Project-URL: Homepage, https://github.com/BlockScience/koi-net/
6
6
  Author-email: Luke Miller <luke@block.science>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "koi-net"
7
- version = "1.0.0-beta.14"
7
+ version = "1.0.0-beta.15"
8
8
  description = "Implementation of KOI-net protocol in Python"
9
9
  authors = [
10
10
  {name = "Luke Miller", email = "luke@block.science"}
@@ -9,6 +9,8 @@ from .handler import KnowledgeHandler, HandlerType, STOP_CHAIN
9
9
  from .knowledge_object import KnowledgeObject, KnowledgeSource
10
10
  from ..protocol.event import Event, EventType
11
11
  from ..protocol.edge import EdgeProfile, EdgeStatus, EdgeType
12
+ from ..protocol.node import NodeProfile
13
+ from ..protocol.helpers import generate_edge_bundle
12
14
 
13
15
  logger = logging.getLogger(__name__)
14
16
 
@@ -124,6 +126,57 @@ def edge_negotiation_handler(processor: ProcessorInterface, kobj: KnowledgeObjec
124
126
 
125
127
  # Network handlers
126
128
 
129
+ @KnowledgeHandler.create(HandlerType.Network, rid_types=[KoiNetNode])
130
+ def coordinator_contact(processor: ProcessorInterface, kobj: KnowledgeObject):
131
+ node_profile = kobj.bundle.validate_contents(NodeProfile)
132
+
133
+ # looking for event provider of nodes
134
+ if KoiNetNode not in node_profile.provides.event:
135
+ return
136
+
137
+ # already have an edge established
138
+ if processor.network.graph.get_edge_profile(
139
+ source=kobj.rid,
140
+ target=processor.identity.rid,
141
+ ) is not None:
142
+ return
143
+
144
+ logger.info("Identified a coordinator!")
145
+ logger.info("Proposing new edge")
146
+
147
+ if processor.identity.profile.node_type == NodeType.FULL:
148
+ edge_type = EdgeType.WEBHOOK
149
+ else:
150
+ edge_type = EdgeType.POLL
151
+
152
+ # queued for processing
153
+ processor.handle(bundle=generate_edge_bundle(
154
+ source=kobj.rid,
155
+ target=processor.identity.rid,
156
+ edge_type=edge_type,
157
+ rid_types=[KoiNetNode]
158
+ ))
159
+
160
+ logger.info("Catching up on network state")
161
+
162
+ payload = processor.network.request_handler.fetch_rids(
163
+ node=kobj.rid,
164
+ rid_types=[KoiNetNode]
165
+ )
166
+ for rid in payload.rids:
167
+ if rid == processor.identity.rid:
168
+ logger.info("Skipping myself")
169
+ continue
170
+ if processor.cache.exists(rid):
171
+ logger.info(f"Skipping known RID '{rid}'")
172
+ continue
173
+
174
+ # marked as external since we are handling RIDs from another node
175
+ # will fetch remotely instead of checking local cache
176
+ processor.handle(rid=rid, source=KnowledgeSource.External)
177
+ logger.info("Done")
178
+
179
+
127
180
  @KnowledgeHandler.create(HandlerType.Network)
128
181
  def basic_network_output_filter(processor: ProcessorInterface, kobj: KnowledgeObject):
129
182
  """Default network handler.
File without changes
File without changes
File without changes
File without changes