private void createAllPeers ( ) throws NetworkConfigurationException { // Sanity checks if ( peers != null ) { throw new NetworkConfigurationException ( "INTERNAL ERROR: peers has already been initialized!" ) ; } peers = new HashMap <> ( ) ; // peers is a JSON object containing a nested object for each peer JsonObject jsonPeers = getJsonObject ( jsonConfig , "peers" ) ; //out("Peers: " + (jsonPeers == null ? "null" : jsonPeers.toString())); if ( jsonPeers != null ) { for ( Entry < String , JsonValue > entry : jsonPeers . entrySet ( ) ) { String peerName = entry . getKey ( ) ; JsonObject jsonPeer = getJsonValueAsObject ( entry . getValue ( ) ) ; if ( jsonPeer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid peer entry: %s" , peerName ) ) ; } Node peer = createNode ( peerName , jsonPeer , "url" ) ; if ( peer == null ) { throw new NetworkConfigurationException ( format ( "Error loading config. Invalid peer entry: %s" , peerName ) ) ; } peers . put ( peerName , peer ) ; } } }
Creates Node instances representing all the peers defined in the config file