# A Blockchain-Based Auction Framework for Location-Aware Services
## 3 The Proposed Blockchain-Based Auction Framework
### Post-Auction
#### 3.3.2 Feedback and Service Index Calculation  
Once the service duration is completed, the participants in the auction (both seller and buyer) are expected to provide feedback about each other. The feedback value can be either positive, negative, or undecided. The feedback is used to recalculate the SI score for the participants. The calculation of the SI takes into account the past feedback about the participants. In this process, each participant is associated with a cumulative weight (\(CW\)) that is used as a credibility indicator for its feedback. Initially, the SI for all participants is determined as undecided.  
```
Data:\(ID\): auction ID \(o\gets determineBestOffer(ID)\) \(b\gets getBuyerID(ID)\) \(notifyBuyer(b,o)\) if\(b\) accepted \(o\)then \(exchangeInformation(b,getBidderID(o))\) processPayment(\(b,o\)) else \(processFee(ID,b)\)

end
```  
**Algorithm 2**settleAuction  
Algorithm 4 illustrates the SI calculation, which is triggered once feedback about a participant is received. Accordingly, if feedback is received from the participant (\(p_{A}\)) about their interaction with the participant (\(p_{B}\)), the cumulative weight for the second participant (\(p_{B}\)) will be recalculated as follows:  
\[CW(p_{B})=F\times\frac{MAX_{CW}+CW(p_{A})}{2\times MAX_{CW}}+CW(p_{B}) \tag{3}\]  
where \(F\) represents the feedback provided by participant (1: positive, \(-1\): negative, 0: undecided) and \(MAX_{CW}\) represents the maximum weight assigned for a participant. The weight of participant \(p_{B}\) will be updated by adding a value between \(-1\) and \(1\). Furthermore,the value of the update depends on the weight of the feedback provider, and the feedback provided by a participant with a high weight has more impact than feedback provided by the lower-weight participant. The SI for participant \(p_{B}\) will be changed based on its new cumulative weight (\(CW(p_{B})\)). If the value of the participant's weight is greater than one, the SI will become positive. However, if the value of the participant's weight is less than zero, the SI will become negative. A weight value between 0 and 1 results in an \"undecided\" SI to be assigned to the participant. The presence of the gap window [0-1] aims to determine the SI based on the overall cumulative feedback provided by the participants. Accordingly, switching a participant's SI from negative to positive requires consistent efforts to provide a reliable service. In contrast, more than one negative feedback is required to switch a participant's SI from positive to negative. The size of the gap window is adjustable, and reducing this size might result in the frequent shifting of a participant's SI from one status to the other. Furthermore, increasing the size of this gap window will increase the effort required from a participant to change the status of their SI. Furthermore, the initial cumulative weight for each participant is assigned to be the middle of the gap window (0.5). Such a placement virtually locates the participant at the same distance from the positive and the negative groups.  
```
Data:\(TF\): total calculated fees, \(o_{w}\):winning offer, \(O\): submitted offers Result:\(S\): eligible bidders shares
1\(O^{\prime}\leftarrow\{O\}/o_{w}\)
2\(avg\gets calculateAVG(O^{\prime})\)
3\(MAX_{o}\gets IdentifyMAX(O^{\prime})\)
4\(E\leftarrow\emptyset\)
5 if\(|O^{\prime}|\
eq 0\)then
6 for\(o_{i}\in O^{\prime}\)do
7 if\(o_{i}>avg\)then
8\(w(p_{i})=\frac{o_{w}}{o_{i}-o_{w}}\)
9 add \(o_{i}\) to \(E\)
10
11 end if
12 calculateShare( \(E\))
13 else
14\(s(p_{w})=TF\)
15 end if return\(S\)
```  
**Algorithm 3**distributeRewards