@@ -58,7 +58,7 @@ pub enum InitializationError {
58
58
pub fn initialize (
59
59
ipfs_path : & Path ,
60
60
bits : NonZeroU16 ,
61
- profile : Profile ,
61
+ profiles : Vec < Profile > ,
62
62
) -> Result < ( ) , InitializationError > {
63
63
let config_path = ipfs_path. join ( "config" ) ;
64
64
@@ -67,10 +67,14 @@ pub fn initialize(
67
67
. and_then ( |_| {
68
68
fs:: File :: create ( & config_path) . map_err ( InitializationError :: ConfigCreationFailed )
69
69
} )
70
- . and_then ( |config_file| create ( config_file, bits, profile ) )
70
+ . and_then ( |config_file| create ( config_file, bits, profiles ) )
71
71
}
72
72
73
- fn create ( config : File , bits : NonZeroU16 , profile : Profile ) -> Result < ( ) , InitializationError > {
73
+ fn create (
74
+ config : File ,
75
+ bits : NonZeroU16 ,
76
+ profiles : Vec < Profile > ,
77
+ ) -> Result < ( ) , InitializationError > {
74
78
use multibase:: Base :: Base64Pad ;
75
79
use prost:: Message ;
76
80
use std:: io:: BufWriter ;
@@ -82,19 +86,6 @@ fn create(config: File, bits: NonZeroU16, profile: Profile) -> Result<(), Initia
82
86
return Err ( InitializationError :: InvalidRsaKeyLength ( bits) ) ;
83
87
}
84
88
85
- // if profiles.len() != 1 || profiles[0] != "test" || profiles[0] != "default" {
86
- // // profiles are expected to be (comma separated) "test" as there are no bootstrap peer
87
- // // handling yet. the conformance test cases seem to init `go-ipfs` in this profile where
88
- // // it does not have any bootstrap nodes, and multi node tests later call swarm apis to
89
- // // dial the nodes together.
90
- // return Err(InitializationError::InvalidProfile(profiles));
91
- // }
92
-
93
- let api_addrs = match profile {
94
- Profile :: Test => "127.0.0.1:0" ,
95
- Profile :: Default => "127.0.0.1:4004" ,
96
- } ;
97
-
98
89
let pk = openssl:: rsa:: Rsa :: generate ( bits as u32 )
99
90
. map_err ( |e| InitializationError :: KeyGeneration ( Box :: new ( e) ) ) ?;
100
91
@@ -133,6 +124,19 @@ fn create(config: File, bits: NonZeroU16, profile: Profile) -> Result<(), Initia
133
124
134
125
let private_key = Base64Pad . encode ( & private_key) ;
135
126
127
+ if profiles. len ( ) != 1 {
128
+ // profiles are expected to be (comma separated) "test" as there are no bootstrap peer
129
+ // handling yet. the conformance test cases seem to init `go-ipfs` in this profile where
130
+ // it does not have any bootstrap nodes, and multi node tests later call swarm apis to
131
+ // dial the nodes together.
132
+ unimplemented ! ( "Multiple profiles are currently unsupported!" )
133
+ }
134
+
135
+ let api_addrs = match profiles[ 0 ] {
136
+ Profile :: Test => "127.0.0.1:0" ,
137
+ Profile :: Default => "127.0.0.1:4004" ,
138
+ } ;
139
+
136
140
let config_contents = CompatibleConfigFile {
137
141
identity : Identity {
138
142
peer_id,
0 commit comments