anchor.diff:            port              :: http_uri:port(),
             path              :: http_uri:path(),
             last_seen = 0     :: integer(), % Erlang system time (POSIX time)
  +          expire            :: undefined | integer(), %% Erlang system time: when to drop this peer
             last_pings = []   :: [integer()], % Erlang system time
             ping_tref         :: reference() | undefined,
             trusted = false   :: boolean() % Is it a pre-configured peer
  
positive.code:                     [A]     -> [T,A];
                      [A,B|_] -> [T,A,B]
                  end,
      LastSeen = case Res of
                     ok    -> T;
                     error -> Peer#peer.last_seen
                 end,
      Peer#peer{last_seen = LastSeen, last_pings = LastPings}.
  
  save_ping_timer(TRef, #peer{ping_tref = Prev} = Peer) ->
      case Prev of
  
negative.code:         {value, _Hash, Peer} ->
              update_ping_metrics(Res),
              Peer1 = save_ping_event(Res, Time, Peer),
              %% drop an errored peer if it has expired
              case Time > Peer1#peer.expire andalso not Peer#peer.trusted of
                   true ->
                       State#state{peers = remove_peer(Peer, State#state.peers), 
                                   errored = gb_sets:delete_any(
                                              uri_of_peer(Peer), State#state.errored)};
                   false ->
                       Peer2 = start_ping_timer(CalcF, Peer1),
                       Peers = enter_peer(Peer2, State#state.peers),
                       Errored = update_errored(Res, uri_of_peer(Peer), State#state.errored),
                       State#state{peers = Peers, errored = Errored}
              end
      end.
  
  update_ping_metrics(Res) ->
  