mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-1120] Removed closure in NetAdapter.onConnectedHanlder * [NOD-1120] Implement all connection manager methods * [NOD-1120] Integrated connmanager into kaspad + added call for dnsseeder * [NOD-1120] Allow buffer to not be bytes.Buffer * [NOD-1120] Added timeout to connect * [NOD-1120] Don't enter connections to add loop if none needed * [NOD-1120] Add call for addressManager.Good * [NOD-1120] Minor bug fixes * [NOD-1120] Remove errChan from grpcConnection * [NOD-1120] Add comments to exported methods * [NOD-1120] cancel the context for DialContext in gRPCServer.Connect * [NOD-1120] Don't try to remove from connSet a connection that doesn't exist * [NOD-1120] add ok bool to connectionSet.get * [NOD-1120] Remove overuse of if-else in checkConnectionRequests * [NOD-1120] Made some order in ConnectionManager * [NOD-1120] Moved checkIncomingConnections to it's own file * [NOD-1120] cleanup in checkOutgoingConnections * [NOD-1120] Cleanup in SeedDNS, and move call outside of connection manager * [NOD-1120] Add check that both --connect and --addpeer aren't used * [NOD-1120] Move dial timeout to constant * [NOD-1120] Enhance comment * [NOD-1120] Log connection failure out of initiateConnection * [NOD-1148] Reshuffle checkRequestedConnections to make more sense * [NOD-1120] Move continue to correct place + reshuffle logging code * [NOD-1120] Don't expose server.Connection outside netAdapter - expose a wrapper instead * [NOD-1120] Add comments * [NOD-1120] Don't return the connection from netAdapter.Connect() * [NOD-1120] Use .Address as key for connectionSet * [NOD-1120] Fix minRetryDuration usage * [NOD-1120] Remove the correct number of incoming connections * [NOD-1120] Add comment * [NOD-1120] Rename connSet -> incomingConnectionSet * [NOD-1120] fix grammar
31 lines
721 B
Go
31 lines
721 B
Go
package connmanager
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/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
|
|
}
|