@Test public void checkCoinNameExistOneContract() { HashMap<String, String> coins = new HashMap<>(); coins.put("Contract", ""); assertEquals("Contract(1)", checkCoinNameExist("Contract", coins)); }
static String checkCoinNameExist(String coinName, Map<String, String> coins) { if(coins.containsKey(coinName)) { String nameWithBrace = coinName + "("; int number = 0; for (String existingName : coins.keySet()){ if(existingName.contains(nameWithBrace)){ int parsedNumber = parseNumberOfDuplicateName(nameWithBrace.length(), existingName); if(parsedNumber > number) number = parsedNumber; } } return coinName + "(" + ++number + ")"; } return coinName; }
SmartContractsUtils { static String checkCoinNameExist(String coinName, Map<String, String> coins) { if(coins.containsKey(coinName)) { String nameWithBrace = coinName + "("; int number = 0; for (String existingName : coins.keySet()){ if(existingName.contains(nameWithBrace)){ int parsedNumber = parseNumberOfDuplicateName(nameWithBrace.length(), existingName); if(parsedNumber > number) number = parsedNumber; } } return coinName + "(" + ++number + ")"; } return coinName; } }
SmartContractsUtils { static String checkCoinNameExist(String coinName, Map<String, String> coins) { if(coins.containsKey(coinName)) { String nameWithBrace = coinName + "("; int number = 0; for (String existingName : coins.keySet()){ if(existingName.contains(nameWithBrace)){ int parsedNumber = parseNumberOfDuplicateName(nameWithBrace.length(), existingName); if(parsedNumber > number) number = parsedNumber; } } return coinName + "(" + ++number + ")"; } return coinName; }  }
SmartContractsUtils { static String checkCoinNameExist(String coinName, Map<String, String> coins) { if(coins.containsKey(coinName)) { String nameWithBrace = coinName + "("; int number = 0; for (String existingName : coins.keySet()){ if(existingName.contains(nameWithBrace)){ int parsedNumber = parseNumberOfDuplicateName(nameWithBrace.length(), existingName); if(parsedNumber > number) number = parsedNumber; } } return coinName + "(" + ++number + ")"; } return coinName; }  static List<ByteBuffer> getSmartsListFromField(String field); static byte[] generateSmartContractAddress(byte[] deployerAddress, long transactionId, List<ByteCodeObjectData> byteCodeObjects); static void saveSmartInTokenList(ObjectKeeper<ConcurrentHashMap<String, String>> coinsKeeper, String coinName, BigDecimal balance, String smartContractAddress); static int parseNumberOfDuplicateName(int identityPieceIndex, String coinName); static String generateSmartContractHashState(byte[] byteCode); }
SmartContractsUtils { static String checkCoinNameExist(String coinName, Map<String, String> coins) { if(coins.containsKey(coinName)) { String nameWithBrace = coinName + "("; int number = 0; for (String existingName : coins.keySet()){ if(existingName.contains(nameWithBrace)){ int parsedNumber = parseNumberOfDuplicateName(nameWithBrace.length(), existingName); if(parsedNumber > number) number = parsedNumber; } } return coinName + "(" + ++number + ")"; } return coinName; }  static List<ByteBuffer> getSmartsListFromField(String field); static byte[] generateSmartContractAddress(byte[] deployerAddress, long transactionId, List<ByteCodeObjectData> byteCodeObjects); static void saveSmartInTokenList(ObjectKeeper<ConcurrentHashMap<String, String>> coinsKeeper, String coinName, BigDecimal balance, String smartContractAddress); static int parseNumberOfDuplicateName(int identityPieceIndex, String coinName); static String generateSmartContractHashState(byte[] byteCode);  }