@@ -64,7 +64,13 @@ void keyfile_singleton::keydata_load()
64
64
std::for_each (first, bfs::directory_iterator (), [this ](const auto & unit) {
65
65
try {
66
66
fc_light::variant j_keyfile = open_keyfile (unit.path ().c_str ());
67
- m_keydata_map.insert (j_keyfile.as <keyfile_format::keyfile_t >());
67
+ auto keyfile = j_keyfile.as <keyfile_format::keyfile_t >();
68
+ auto & ind = prim_index ();
69
+ auto it = ind.find (keyfile.public_key ());
70
+ if (it == ind.end ())
71
+ m_keydata_map.insert (keyfile);
72
+ else
73
+ m_keydata_map.replace (it, keyfile);
68
74
}
69
75
catch (fc_light::parse_error_exception& er) {
70
76
return print_exception (unit.path (), er);
@@ -98,9 +104,18 @@ void keyfile_singleton::signlog_load()
98
104
try {
99
105
fc_light::variant j_keyfile = open_keyfile (unit.path ().c_str ());
100
106
auto file = j_keyfile.as <keyfile_format::signlog_file_t >();
101
- auto res = m_signlog_map.insert (signlog_map_t::value_type (file.public_key ,log_records_t ()));
102
- FC_LIGHT_ASSERT (res.second );
103
- auto it = res.first ;
107
+ auto found_it = m_signlog_map.find (file.public_key );
108
+ auto it = m_signlog_map.end ();
109
+ if (found_it == m_signlog_map.end ())
110
+ {
111
+ auto res = m_signlog_map.insert (signlog_map_t::value_type (file.public_key ,log_records_t ()));
112
+ FC_LIGHT_ASSERT (res.second );
113
+ it = res.first ;
114
+ } else
115
+ {
116
+ found_it->second .clear ();
117
+ it = found_it;
118
+ }
104
119
auto & logmap = it->second ;
105
120
std::copy (file.sign_events .begin (), file.sign_events .end (), std::inserter (logmap, logmap.begin ()));
106
121
}
0 commit comments