CORDA-1480: In Demobench, saving a profile, opening it, and adding a node skips next name (#4113)

* Fixes Github #3800 ,Jira Issue CORDA-1480

* did the requested changes

* does the requested changes

* Did requested changes

* Does the required changes
This commit is contained in:
Vardan Nadkarni 2018-11-23 15:48:03 +05:30 committed by Joel Dudley
parent 51adf9b678
commit e14421b7b4
4 changed files with 18 additions and 2 deletions

View File

@ -203,6 +203,7 @@ see changes to this list.
* tomtau
* Tudor Malene (R3)
* Tushar Singh Bora (Accenture)
* Vardan Nadkarni (Persistent Systems Limited)
* varunkm
* Venelin Stoykov (INDUSTRIA)
* verymahler

View File

@ -165,6 +165,7 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
nodeInfoFilesCopier.reset()
notaryIdentity = null
networkParametersCopier = null
SuggestedDetails.reset()
}
/**

View File

@ -27,7 +27,20 @@ object SuggestedDetails {
private var cursor = 0
val nextBank: Pair<String, String> get() = banks[cursor++ % banks.size]
fun nextBank(exists: (String) -> Boolean): Pair<String, String> {
for (i in 0 until banks.size) {
val bank = banks[cursor]
if (!exists(bank.first)) {
return bank
}
cursor = (cursor + 1) % banks.size
}
return banks[cursor]
}
fun reset() {
cursor = 0
}
}
class NodeData {

View File

@ -206,7 +206,8 @@ class NodeTabView : Fragment() {
model.webPort.value = nodeController.nextPort
model.h2Port.value = nodeController.nextPort
val defaults = SuggestedDetails.nextBank
val defaults = SuggestedDetails.nextBank(nodeController::nameExists)
model.legalName.value = defaults.first
model.nearestCity.value = CityDatabase[defaults.second]