The explosive increase of vehicles and the emergence of novel businesses such as driverless driving have presented fresh challenges to the data security of the IoVs(Internet of Vehicles). To ensure data security, a trusted decentralized distributed storage approach for managing and storing information proves to be a feasible solution. The blockchain enables distributed nodes to jointly maintain a consistent and tamper-proof ledger, facilitating trusted storage and transmission of information among distributed nodes. However, the consensus mechanism of the blockchain demands that miners in the system possess strong computing power for mining computations. Unfortunately, the performance of nodes in the IoVs is limited and fails to meet these requirements, significantly restricting the application of the blockchain in the IoVs. This paper proposes a blockchain consensus mechanism based on edge computing, with roadside node RSU serving as the edge server to undertake the task of miners for mining, in order to address the issues of insufficient computing power and unstable topology of vehicle nodes. Simulation experiments indicate that the consensus mechanism proposed in this paper has lower total costs, including total energy consumption and delay, compared to the PoW consensus mechanism that uses vehicle nodes as miners.