@@ -28,52 +28,64 @@ pub const FARCASTER_TESTNET_ELECTRUM_SERVER: &str = "ssl://blockstream.info:993"
2828pub const FARCASTER_TESTNET_MONERO_DAEMON : & str = "http://stagenet.community.rino.io:38081" ;
2929pub const FARCASTER_TESTNET_MONERO_RPC_WALLET : & str = "http://localhost:38083" ;
3030
31+ pub const GRPC_BIND_IP_ADDRESS : & str = "127.0.0.1" ;
32+
3133#[ derive( Deserialize , Serialize , Debug , Clone ) ]
3234#[ serde( crate = "serde_crate" ) ]
3335pub struct Config {
3436 /// Farcasterd configuration
3537 pub farcasterd : Option < FarcasterdConfig > ,
38+ /// Sets the grpc server port, if none is given, no grpc server is run
39+ pub grpc : Option < GrpcConfig > ,
3640 /// Syncer configuration
3741 pub syncers : Option < SyncersConfig > ,
3842}
3943
4044impl Config {
41- /// Returns if auto-funding functionality is enable
45+ /// Returns if auto-funding functionality is enabled
4246 pub fn is_auto_funding_enable ( & self ) -> bool {
4347 match & self . farcasterd {
4448 Some ( FarcasterdConfig {
45- auto_funding : Some ( AutoFundingConfig { auto_fund , .. } ) ,
46- grpc : _ ,
47- } ) => * auto_fund ,
49+ auto_funding : Some ( AutoFundingConfig { enable , .. } ) ,
50+ ..
51+ } ) => * enable ,
4852 _ => false ,
4953 }
5054 }
5155
52- /// Returns if grpc port is set
56+ /// Returns if grpc is enabled
5357 pub fn is_grpc_enable ( & self ) -> bool {
54- match & self . farcasterd {
55- Some ( FarcasterdConfig {
56- auto_funding : _,
57- grpc : Some ( GrpcConfig { use_grpc, .. } ) ,
58- } ) => * use_grpc,
58+ match & self . grpc {
59+ Some ( GrpcConfig { enable, .. } ) => * enable,
5960 _ => false ,
6061 }
6162 }
6263
64+ /// Returns the Grcp bind ip address, if not set return the default value
65+ pub fn grpc_bind_ip ( & self ) -> String {
66+ match & self . grpc {
67+ Some ( GrpcConfig {
68+ bind_ip : Some ( bind_ip) ,
69+ ..
70+ } ) => bind_ip. clone ( ) ,
71+ _ => String :: from ( GRPC_BIND_IP_ADDRESS ) ,
72+ }
73+ }
74+
6375 /// Returns the auto-funding configuration for a given network if enable, if None no
6476 /// configuration is found
6577 pub fn get_auto_funding_config ( & self , network : Network ) -> Option < AutoFundingServers > {
6678 match & self . farcasterd {
6779 Some ( FarcasterdConfig {
6880 auto_funding :
6981 Some ( AutoFundingConfig {
70- auto_fund ,
82+ enable ,
7183 mainnet,
7284 testnet,
7385 local,
7486 } ) ,
75- grpc : _ ,
76- } ) if * auto_fund => match network {
87+ ..
88+ } ) if * enable => match network {
7789 Network :: Mainnet => mainnet. clone ( ) ,
7890 Network :: Testnet => testnet. clone ( ) ,
7991 Network :: Local => local. clone ( ) ,
@@ -95,6 +107,7 @@ impl Default for Config {
95107 fn default ( ) -> Self {
96108 Config {
97109 farcasterd : None ,
110+ grpc : None ,
98111 syncers : Some ( SyncersConfig :: default ( ) ) ,
99112 }
100113 }
@@ -105,24 +118,24 @@ impl Default for Config {
105118pub struct FarcasterdConfig {
106119 /// Sets the auto-funding parameters, default to no auto-fund
107120 pub auto_funding : Option < AutoFundingConfig > ,
108- /// Sets the grpc server port, if none is given, no grpc server is run
109- pub grpc : Option < GrpcConfig > ,
110121}
111122
112123#[ derive( Deserialize , Serialize , Debug , Clone ) ]
113124#[ serde( crate = "serde_crate" ) ]
114125pub struct GrpcConfig {
115126 /// Use grpc functionality
116- pub use_grpc : bool ,
127+ pub enable : bool ,
117128 /// Grpc port configuration
118- pub port : u64 ,
129+ pub bind_port : u16 ,
130+ /// Grpc listening ip address
131+ pub bind_ip : Option < String > ,
119132}
120133
121134#[ derive( Deserialize , Serialize , Debug , Clone ) ]
122135#[ serde( crate = "serde_crate" ) ]
123136pub struct AutoFundingConfig {
124137 /// Use auto-funding functionality
125- pub auto_fund : bool ,
138+ pub enable : bool ,
126139 /// Mainnet auto-funding configuration
127140 pub mainnet : Option < AutoFundingServers > ,
128141 /// Testnet auto-funding configuration
0 commit comments