mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-27 15:53:57 +00:00
31 lines
745 B
Go
31 lines
745 B
Go
package connmanager
|
|
|
|
import (
|
|
"github.com/c4ei/yunseokyeol/infrastructure/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
|
|
}
|