[tor-commits] [tor/master] Extract the add-or-replace-keypin logic into a new function