Skip to content

Commit

Permalink
[#1028] Runtime switch of lightwalletd servers (#1044)
Browse files Browse the repository at this point in the history
- comments addressed
  • Loading branch information
LukasKorba committed Feb 14, 2024
1 parent 0faa8d1 commit 551ce82
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ extension ZcashSDKEnvironment {
// remove http:// or https:// from the input if present
var input = storedCustomServer

if input.contains("https://") {
input = String(input.dropFirst(8))
} else if input.contains("http://") {
input = String(input.dropFirst(7))
let http = "http://"
let https = "https://"
if input.contains(https) {
input = String(input.dropFirst(https.count))
} else if input.contains(http) {
input = String(input.dropFirst(http.count))
}

let split = input.split(separator: ":")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ extension ZcashSDKEnvironment: DependencyKey {
// Some endpoint is set by a user so we initialize the SDK with this one
return endpoint
} else {
// Endpoint failed, fallback to hardcoded mainnet
// Initalization of LightWalletEndpoint failed, fallback to hardcoded one,
// setting the mainnet key to the storage to reflect that
userDefaults.setValue(ZcashSDKEnvironment.Servers.mainnet.rawValue, udKey)
}
}
Expand Down
20 changes: 20 additions & 0 deletions modules/Sources/Utils/SensitiveData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ extension BlockHeight {
public var redacted: RedactableBlockHeight { RedactableBlockHeight(self) }
}

// MARK: - Redactable AccountBalance & SynchronizerState

/// Redactable holder for a block height.
public struct RedactableAccountBalance: Equatable, Redactable {
public let data: AccountBalance?

public init(_ data: AccountBalance? = nil) { self.data = data }
}

/// Utility that converts a block height to a redacted counterpart.
extension AccountBalance {
public var redacted: RedactableAccountBalance? { RedactableAccountBalance(self) }
}

extension SynchronizerState {
public var redacted: SynchronizerState {
SynchronizerState
}
}

// MARK: - Redactable Int64

/// Redactable holder for an Int64.
Expand Down

0 comments on commit 551ce82

Please sign in to comment.