@@ -253,6 +253,7 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
253253 protected syncNodeGraphHandler = async (
254254 ctx : ContextTimed ,
255255 _taskInfo : TaskInfo | undefined ,
256+ network : string | undefined ,
256257 initialNodes : Array < [ NodeIdEncoded , NodeAddress ] > ,
257258 connectionConnectTimeoutTime : number | undefined ,
258259 ) => {
@@ -299,6 +300,14 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
299300 }
300301 if ( ctx . signal . aborted ) return ;
301302
303+ if ( network != null ) {
304+ try {
305+ await this . claimNetwork ( successfulConnections [ 0 ] . value . nodeId , network ) ;
306+ } catch {
307+ await this . switchNetwork ( network ) ;
308+ }
309+ }
310+
302311 // Attempt a findNode operation looking for ourselves
303312 await this . findNode (
304313 {
@@ -1877,10 +1886,10 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
18771886 ) ;
18781887
18791888 // Error out if a network access claim already exists
1880- if ( await this . getClaimNetworkAccess ( network , tran ) != null ) {
1881- throw new Error ( 'TMP network access claim already exists' )
1889+ if ( ( await this . getClaimNetworkAccess ( network , tran ) ) != null ) {
1890+ throw new Error ( 'TMP network access claim already exists' ) ;
18821891 }
1883-
1892+
18841893 const encodedNetworkAuthority = claimsUtils . generateSignedClaim (
18851894 claimNetworkAuthority . toSigned ( ) ,
18861895 ) ;
@@ -2793,6 +2802,7 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
27932802 *
27942803 */
27952804 public syncNodeGraph (
2805+ network : string | undefined ,
27962806 initialNodes : Array < [ NodeId , NodeAddress ] > ,
27972807 connectionConnectTimeoutTime ?: number ,
27982808 blocking ?: boolean ,
@@ -2801,6 +2811,7 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
28012811 @startStop . ready ( new nodesErrors . ErrorNodeManagerNotRunning ( ) )
28022812 @decorators . timedCancellable ( true )
28032813 public async syncNodeGraph (
2814+ network : string ,
28042815 initialNodes : Array < [ NodeId , NodeAddress ] > ,
28052816 connectionConnectTimeoutTime : number = this . connectionConnectTimeoutTime ,
28062817 blocking : boolean = false ,
@@ -2823,6 +2834,7 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
28232834 await this . syncNodeGraphHandler (
28242835 ctx ,
28252836 undefined ,
2837+ network ,
28262838 initialNodesParameter ,
28272839 connectionConnectTimeoutTime ,
28282840 ) ;
@@ -2832,7 +2844,11 @@ class NodeManager<Manifest extends AgentClientManifestNodeManager> {
28322844 delay : 0 ,
28332845 handlerId : this . syncNodeGraphHandlerId ,
28342846 lazy : true ,
2835- parameters : [ initialNodesParameter , connectionConnectTimeoutTime ] ,
2847+ parameters : [
2848+ network ,
2849+ initialNodesParameter ,
2850+ connectionConnectTimeoutTime ,
2851+ ] ,
28362852 path : [ this . tasksPath , this . syncNodeGraphHandlerId ] ,
28372853 priority : 0 ,
28382854 } ) ;
0 commit comments