Inital implementation of trie
This commit is contained in:
parent
8ce921987f
commit
ec3d656beb
8 changed files with 325 additions and 239 deletions
22
src/routing.go
Normal file
22
src/routing.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
/* Thread-safe high level functions for cryptkey routing.
|
||||
*
|
||||
*/
|
||||
|
||||
type RoutingTable struct {
|
||||
IPv4 *Trie
|
||||
IPv6 *Trie
|
||||
mutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (table *RoutingTable) RemovePeer(peer *Peer) {
|
||||
table.mutex.Lock()
|
||||
defer table.mutex.Unlock()
|
||||
table.IPv4 = table.IPv4.RemovePeer(peer)
|
||||
table.IPv6 = table.IPv6.RemovePeer(peer)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue