mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 23:12:31 +00:00

* [NOD-1223] Move all network stuff into a new network package. * [NOD-1223] Delete the unused package testutil. * [NOD-1223] Move infrastructure stuff into a new instrastructure package. * [NOD-1223] Move domain stuff into a new domain package.
31 lines
729 B
Go
31 lines
729 B
Go
package connmanager
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/network/netadapter"
|
|
)
|
|
|
|
type connectionSet map[string]*netadapter.NetConnection
|
|
|
|
func (cs connectionSet) add(connection *netadapter.NetConnection) {
|
|
cs[connection.Address()] = connection
|
|
}
|
|
|
|
func (cs connectionSet) remove(connection *netadapter.NetConnection) {
|
|
delete(cs, connection.Address())
|
|
}
|
|
|
|
func (cs connectionSet) get(address string) (*netadapter.NetConnection, bool) {
|
|
connection, ok := cs[address]
|
|
return connection, ok
|
|
}
|
|
|
|
func convertToSet(connections []*netadapter.NetConnection) connectionSet {
|
|
connSet := make(connectionSet, len(connections))
|
|
|
|
for _, connection := range connections {
|
|
connSet[connection.Address()] = connection
|
|
}
|
|
|
|
return connSet
|
|
}
|