# BloodChain: A Blood Donation Network Managed by Blockchain Technologies
## 5 Implementation
### Algorithms
Figure 6 depicts the measurement results of requests that perform the data update function for blood samples. In this feature, the number of workers increased by two compared to the initial data initialization request; the number of requests is also increased from 1000 requests to 10,000 requests per second per worker. The number of successful requests increased slightly from the lowest level of 15,235 to the highest of 16,206 requests per second. However, the number of failed requests is higher than that in scenario number one because the number of workers has increased. This means that the system takes longer when the number of users increases. It takes more time to process the received requests, and the number of failed requests increases. ### Second Scenario

In this second scenario, the article measures and evaluates the latency corresponding to three functions of data initialization, query, and update. Figure 7 shows the latency of the data initialization function of the blood samples, in which most of the three latency levels are stable. Specifically, the maximum latency index fluctuates in the range of 500 s when the number of requests increases from 1000 to 10,000 requests. However, a particular case occurs in case 6 with 6000 requests per second; the latency increases quite a lot at 2240.21 s, which may occur when the system has a bottleneck in processing transactions, so incoming transactions take longer to complete processing. Nevertheless, at the two indicators Min and Avg latency, the processing time for requests is still kept at a stable level of 363.16 s/request and 0.64 s/request, respectively. Figure 5: The results of the request data functions. Figure 6: The results of the update data functions. The latency of data query requests is shown in Figure 8. The maximum latency index fluctuates quite strongly from 1.41 s/request to 4.64 s/request. However, the system's processing time gradually decreased and remained stable when the number of requests increased from 1000 to 10,000. The highest value is 4.65 s for a total of 2000 requests. Figure 8 describes the latency of requests to query data of all users in the system. Minimum latency 0.01-0.02 and average latency 0.19-0.82 are minimal even when the number of requests increases to 10,000 requests simultaneously. The maximum value of Max latency is 4.65 s, corresponding to the situation of 10 users sending 2000 requests to the system at the same time. Finally, the latency of the data update function of the blood samples is also shown in Figure 9. The latency of the requests is kept stable when the number of requests increases from 1000 to 10,000 requests. However, the processing time is at the highest level compared to 2 requests to initiate and query data; this happens when the system starts querying the data and then updates the data fields that requested data and stores new ones. The maximum value of Max Latency is 795.4 s for 1000 requests; in addition, the rest of the cases are stable with a delay of over 700 s.

### Security and Privacy Discussion

The blockchain plays a vital role in the modern system; this model meets the transparency and availability requirements for the supply chain [6, 47, 48]. However, the blockchain-based system still has some problems that are listed in [49], especially in the security and

Figure 8: The latency of the request data functions. Figure 7: The latency of the data initialization functions. Figure 9: The latency of the update data functions. privacy aspect. To improve the security and privacy issues in the blockchain-based blood donation system, we consider the authorization for the parties in the same transaction and the flexibility in the medical environment. For the authorization aspect, we will exploit attribute-based access control (ABAC) [50, 51] to manage the access control process. The main benefit of this model is that only authorized users can access the release data. In addition, the query rewriting can apply for the complex context where the released data is shared to multiple users [52, 53].