Change g_peers to vector data structor
Fix some bugs, but still have the bug of generating duplicate peers when applying event dependencies.