class_docstr: A helper class that stores current-best GET results with metadata
class_docstr_tok: ["A","helper","class","that","stores","current-best","GET","results","with","metadata"]
code: def add_candidate(
      self,
      candidate: Optional[
          ValueWithExpiration[Union[BinaryDHTValue, DictionaryDHTValue]]
      ],
      source_node_id: Optional[DHTID],
  ):
      if self.finished or candidate is None:
          return
      elif isinstance(
          candidate.value, DictionaryDHTValue
      ) and isinstance(self.binary_value, DictionaryDHTValue):
          self.binary_value.maxsize = max(
              self.binary_value.maxsize, candidate.value.maxsize
          )
          for subkey, subentry in candidate.value.items():
              self.binary_value.store(
                  subkey, subentry.value, subentry.expiration_time
              )
      elif candidate.expiration_time > (
          self.expiration_time or float("-inf")
      ):
          self.binary_value = candidate.value
  
      if candidate.expiration_time > (
          self.expiration_time or float("-inf")
      ):
          self.expiration_time = candidate.expiration_time
          self.source_node_id = source_node_id
          if self.expiration_time >= self.sufficient_expiration_time:
              self.finish_search()
  
imports: from __future__ import annotations
  import asyncio
  import dataclasses
  import os
  import random
  from collections import Counter, defaultdict
  from dataclasses import dataclass, field
  from functools import partial
  from typing import Any, Awaitable, Callable, Collection, DefaultDict, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
  from multiaddr import Multiaddr
  from sortedcontainers import SortedSet
  from hivemind.dht.crypto import DHTRecord, RecordValidatorBase
  from hivemind.dht.protocol import DHTProtocol
  from hivemind.dht.routing import DHTID, BinaryDHTValue, DHTKey, DHTValue, Subkey, get_dht_time
  from hivemind.dht.storage import DictionaryDHTValue
  from hivemind.dht.traverse import traverse_dht
  from hivemind.p2p import P2P, PeerID
  from hivemind.utils import MSGPackSerializer, SerializerBase, get_logger
  from hivemind.utils.auth import AuthorizerBase
  from hivemind.utils.timed_storage import DHTExpiration, TimedStorage, ValueWithExpiration
label_desc: Use image node_id 1 for calling the _SearchState obj's underlying member method code with example usage: obj.add_candidate(candidate, source_node_id) without return types