| 346 | # Send my hashfield to peer |
| 347 | # Return: True if sent |
| 348 | def sendMyHashfield(self): |
| 349 | if self.connection and self.connection.handshake.get("rev", 0) < 510: |
| 350 | return False # Not supported |
| 351 | if self.time_my_hashfield_sent and self.site.content_manager.hashfield.time_changed <= self.time_my_hashfield_sent: |
| 352 | return False # Peer already has the latest hashfield |
| 353 | |
| 354 | res = self.request("setHashfield", {"site": self.site.address, "hashfield_raw": self.site.content_manager.hashfield.tobytes()}) |
| 355 | if not res or "error" in res: |
| 356 | return False |
| 357 | else: |
| 358 | self.time_my_hashfield_sent = time.time() |
| 359 | return True |
| 360 | |
| 361 | def publish(self, address, inner_path, body, modified, diffs=[]): |
| 362 | if len(body) > 10 * 1024 and self.connection and self.connection.handshake.get("rev", 0) >= 4095: |