Toward a Greener Planet Through IoT JOI_20230426_eBook | Page 67

Decentralized Review System for Transparent and Accountable Governance
5.1.3.3 REVIEW ACCOUNT
Within our decentralized review system , the Review account stores all relevant information related to a specific review . This includes all review details , as well as the IPFS addresses of any associated multimedia . This review might include text and multimedia such as audio , video and / or images .
To efficiently manage the storage and retrieval of review data , our On Chain Program utilizes a combination of organization PDAs and review counts as seeds to derive a Program Derived Address ( PDA ) for each review . When we want to fetch all reviews associated with a specific organization , we simply use the organization ’ s PDA and iterate from 0 to review count-1 , using each value to fetch the corresponding review . This approach allows us to easily and efficiently access all reviews of a particular organization .
However , fetching user reviews presents a unique challenge , as review PDAs can only be derived from organization IDs . To address this challenge , we created a separate account specifically for user reviews . We will discuss this in more detail next .
5.1.3.4 USER REVIEW ACCOUNT
A user review account serves as a bridge between the user account and the corresponding review account . It stores the PDA of the corresponding review account . The On Chain Program utilizes the unique identifier of the user who wrote the review and the review count of the user as seeds to derive the user review Program Derived Address ( PDA ). When we want to access all the reviews of a user account , we use its PDA to iterate from 0 to ( review _ count - 1 ), obtaining the user review PDA at each iteration . Subsequently , we read the corresponding user review account to obtain the PDA of the associated review account . From the review account , we can retrieve all the review details . By this means , we can easily access all the reviews of a user .
The review count of the user is incremented every time a new review is added by him / her , ensuring that the new review is included in the set of user reviews .

5.2 ADDING AND STORING REVIEWS

When a user requests to add a review , we first upload the multimedia to IPFS , which returns the content identifiers ( CIDs ). Next , the Onchain Program is invoked . The Onchain program utilizes the user ' s and organization ' s identifiers , along with the review data and corresponding CIDs of the multimedia attachments stored on IPFS , to store the review as a transaction on the blockchain .
Figure 5-2 is the activity diagram depicting how the review account is added to the Blockchain .
62 April 2023