class ShardInfoDownloader {

    public ShardInfo getShardInfo(Long shardId) {
        Objects.requireNonNull(shardId, "shardId is NULL");
        ShardInfo res = null;
        if (goodPeersMap.isEmpty()) { //forced shard import
            return res;
        }
        Set<PeerFileHashSum> goodShardPeers = goodPeersMap.get(shardId);
        if (goodShardPeers == null || goodShardPeers.isEmpty()) {
            return res;
        }
        PeerFileHashSum pfhs = goodShardPeers.iterator().next();
        if (pfhs == null) {
            return res;
        }
        String peerId = pfhs.getPeerId();
        ShardingInfo srdInfo = shardInfoByPeers.get(peerId);
        //in our case we have just reverted array, but it could be in any order. So we should find by iteration
        for (ShardInfo si : srdInfo.getShards()) {
            if (si.shardId.longValue() == shardId.longValue()) {
                res = si;
                break;
            }
        }
        return res;
    }

    @Inject public  ShardInfoDownloader(PeersService peers);

}