lnrpc: reuse common FileExists function
This commit is contained in:
parent
70c874be88
commit
8996a1490d
@ -60,16 +60,6 @@ type Server struct {
|
|||||||
// AutopilotServer gRPC service.
|
// AutopilotServer gRPC service.
|
||||||
var _ AutopilotServer = (*Server)(nil)
|
var _ AutopilotServer = (*Server)(nil)
|
||||||
|
|
||||||
// fileExists reports whether the named file or directory exists.
|
|
||||||
func fileExists(name string) bool {
|
|
||||||
if _, err := os.Stat(name); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new instance of the autopilotrpc Autopilot sub-server. We also
|
// New returns a new instance of the autopilotrpc Autopilot sub-server. We also
|
||||||
// return the set of permissions for the macaroons that we may create within
|
// return the set of permissions for the macaroons that we may create within
|
||||||
// this method. If the macaroons we need aren't found in the filepath, then
|
// this method. If the macaroons we need aren't found in the filepath, then
|
||||||
|
@ -69,16 +69,6 @@ type Server struct {
|
|||||||
// gRPC service.
|
// gRPC service.
|
||||||
var _ SignerServer = (*Server)(nil)
|
var _ SignerServer = (*Server)(nil)
|
||||||
|
|
||||||
// fileExists reports whether the named file or directory exists.
|
|
||||||
func fileExists(name string) bool {
|
|
||||||
if _, err := os.Stat(name); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new instance of the signrpc Signer sub-server. We also return
|
// New returns a new instance of the signrpc Signer sub-server. We also return
|
||||||
// the set of permissions for the macaroons that we may create within this
|
// the set of permissions for the macaroons that we may create within this
|
||||||
// method. If the macaroons we need aren't found in the filepath, then we'll
|
// method. If the macaroons we need aren't found in the filepath, then we'll
|
||||||
@ -96,7 +86,7 @@ func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) {
|
|||||||
// Now that we know the full path of the signer macaroon, we can check
|
// Now that we know the full path of the signer macaroon, we can check
|
||||||
// to see if we need to create it or not.
|
// to see if we need to create it or not.
|
||||||
macFilePath := cfg.SignerMacPath
|
macFilePath := cfg.SignerMacPath
|
||||||
if cfg.MacService != nil && !fileExists(macFilePath) {
|
if cfg.MacService != nil && !lnrpc.FileExists(macFilePath) {
|
||||||
log.Infof("Making macaroons for Signer RPC Server at: %v",
|
log.Infof("Making macaroons for Signer RPC Server at: %v",
|
||||||
macFilePath)
|
macFilePath)
|
||||||
|
|
||||||
|
@ -93,16 +93,6 @@ type WalletKit struct {
|
|||||||
// WalletKitServer gRPC service.
|
// WalletKitServer gRPC service.
|
||||||
var _ WalletKitServer = (*WalletKit)(nil)
|
var _ WalletKitServer = (*WalletKit)(nil)
|
||||||
|
|
||||||
// fileExists reports whether the named file or directory exists.
|
|
||||||
func fileExists(name string) bool {
|
|
||||||
if _, err := os.Stat(name); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates a new instance of the WalletKit sub-RPC server.
|
// New creates a new instance of the WalletKit sub-RPC server.
|
||||||
func New(cfg *Config) (*WalletKit, lnrpc.MacaroonPerms, error) {
|
func New(cfg *Config) (*WalletKit, lnrpc.MacaroonPerms, error) {
|
||||||
// If the path of the wallet kit macaroon wasn't specified, then we'll
|
// If the path of the wallet kit macaroon wasn't specified, then we'll
|
||||||
@ -116,7 +106,7 @@ func New(cfg *Config) (*WalletKit, lnrpc.MacaroonPerms, error) {
|
|||||||
// Now that we know the full path of the wallet kit macaroon, we can
|
// Now that we know the full path of the wallet kit macaroon, we can
|
||||||
// check to see if we need to create it or not.
|
// check to see if we need to create it or not.
|
||||||
macFilePath := cfg.WalletKitMacPath
|
macFilePath := cfg.WalletKitMacPath
|
||||||
if !fileExists(macFilePath) && cfg.MacService != nil {
|
if !lnrpc.FileExists(macFilePath) && cfg.MacService != nil {
|
||||||
log.Infof("Baking macaroons for WalletKit RPC Server at: %v",
|
log.Infof("Baking macaroons for WalletKit RPC Server at: %v",
|
||||||
macFilePath)
|
macFilePath)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user