Using Blockchain in a Reputation-Based Model for Grouping Agents in the Internet of Things