## 5 Algorithm
### RSU Clustering  
In the proposed system, since RSU nodes have limited available storage resources, it is essential to cluster RSUs to form RSU clusters that can efficiently provide full blockchain query services for vehicles. To achieve effective clustering, it is necessary to consider not only the distance between RSU nodes but also the block access preferences of the vehicles served by each RSU. Therefore, we propose RAPSCA, which incorporates both spatial relationships and vehicle access behaviors to optimize clustering. Under the collaborative storage architecture, redundant storage of critical block data within clusters is allowed. This strategy ensures that redundant copies can better satisfy the data needs of multiple nodes, thereby improving overall storage efficiency. The pseudocode for RAPSCA is presented in Algorithm 1. The algorithm consists of six main steps: determining the number of clusters, similarity matrix construction, Laplacian matrix computation, spectral decomposition, feature normalization, and K-means clustering with a minimum capacity constraint. To better illustrate the role of RAPSCA in collaborative storage, we further explain the steps of the algorithm as follows:  
1. Determining the Number of Clusters: The number of clusters can be determined based on the storage resources of RSU nodes in the system and the storage constraints of individual clusters, as follows: \[L=\left\lfloor\frac{\sum_{r\in R}rc_{i}}{\eta\sum_{k=1}^{K}s_{k}}\right\rfloor\] (14) Equation (14) ensures that each cluster satisfies the storage resource constraints imposed by blockchain size requirements within the cluster. Simultaneously, it partitions RSU nodes into the maximum feasible number of clusters to optimally preserve the decentralized characteristics of the system. 2. Similarity Matrix Construction: As mentioned earlier, due to the random block packaging mechanism in blockchain, a single block may contain reputation update records for any vehicle. Therefore, even if vehicles are distributed across different RSUs and have never had direct social interactions, their reputation updates may still be packaged into the same block. From the packaging results, we can infer that RSUs exhibit certain similarities in their preferences for blocks, even if they serve different sets of vehicles. However, modifying the blockchain packaging mechanism to introduce systematic patterns or preferences could compromise the security and decentralization of the blockchain. Thus, this paper assumes that the block packaging process is random and unpredictable. Instead of modifying the packaging mechanism, we analyze the existing block data and their associated vehicle relationships to determine the similarity in block demand among RSU nodes. As previously defined, the set of blocks of interest for vehicle \(v_{m}\) is represented as \(B_{m}\). Since RSU \(r_{i}\) needs to consider the block access probabilities of all vehicles within its coverage area, the set of required blocks for RSU \(r_{i}\) is given by the following:  
\[B_{r_{i}}=\bigcup_{v_{m}\in V^{i}}B_{m} \tag{15}\]  
where \(V^{i}\) represents the set of vehicles within the coverage area of RSU \(r_{i}\). Referring to the interest similarity described in reference [25], we define the weight between RSU nodes \(r_{i}\) and \(r_{j}\) based on their block demand similarity.