code: async def append_entries(self, destination=None):
          
  
          # Send AppendEntries RPC to destination if specified or broadcast to everyone
          destination_list = [destination] if destination else self.state.cluster
          for destination in destination_list:
              data = {
                  'type': 'append_entries',
  
                  'term': self.storage.term,
                  'leader_id': self.id,
                  'commit_index': self.log.commit_index,
  
                  'request_id': self.request_id
              }
  
              next_index = self.log.next_index[destination]
              prev_index = next_index - 1
  
              if self.log.last_log_index >= next_index:
                  data['entries'] = [self.log[next_index]]
  
              else:
                  data['entries'] = []
  
              data.update({
                  'prev_log_index': prev_index,
                  'prev_log_term': self.log[prev_index]['term'] if self.log and prev_index else 0
              })
  
              asyncio.ensure_future(self.state.send(data, destination), loop=self.loop)
docs: AppendEntries RPC — replicate log entries / heartbeat
          Args:
              destination — destination id
  
          Request params:
              term — leader’s term
              leader_id — so follower can redirect clients
              prev_log_index — index of log entry immediately preceding new ones
              prev_log_term — term of prev_log_index entry
              commit_index — leader’s commit_index
  
              entries[] — log entries to store (empty for heartbeat)