Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Update README.md with pseudocode for reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Kofoed Clausen committed Nov 12, 2018
1 parent 22ab930 commit 3a32a33
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -39,4 +39,30 @@ STEPS:
NEXTSUCCESSOR_OF_X = NEWPEER
else:
PEER sends message to SUCCESSOR_OF_PEER: Rerun this function with SUCCESSOR_OF_PEER as PEER
```

### Reorganize network when successor of peer has disconnected
```
ENTRY CONDITION:
PEER detects that SUCCESSOR_OF_PEER (DEAD_PEER) is faulty/disconnected.
STEPS:
if (NEXTSUCCESSOR_OF_PEER == null): // Only peer left
PEER sets SUCCESSOR_OF_PEER = null
return
PEER sets SUCCESSOR_OF_PEER = NEXTSUCCESSOR_OF_PEER
PEER sends message to SUCCESSOR_OF_PEER: Give me the address of your successor (called X)
if (X == DEAD_PEER): // Only two peers left
return
PEER sends message "around the ring" to Y:
if SUCCESSOR_OF_Y == PEER:
if (SUCCESSOR_OF_PEER == Y):
return // The same
else:
Y set NEXTSUCCESSOR_OF_Y = SUCCESSOR_OF_PEER
else:
pass on the message to SUCCESSOR_OF_Y
```

0 comments on commit 3a32a33

Please sign in to comment.