Implementing a Generic Search Function
Description
Currently, our codebase contains specialized search functions like findDealActors and findDealClients. This creates duplication and increases the complexity of our codebase.
Proposal
Replace these specialized functions with a more generic search function, such as findPartyDeal. This would:
- Simplify the codebase
- Reduce code duplication
- Provide more flexibility
Example implementation:
const findPartyDeal = (retrievalTasks, minerId, cid, partyName) => {
const deal = retrievalTasks.find(t => t.cid === cid && t.minerId === minerId);
return deal ? deal[partyName] : undefined;
}
References
Original discussion from PR comments between @pyropy and @bajtos.