[notes][spam] pursuing dgit/gitopia

Undiscussed Horrific Abuse, One Victim of Many gmkarl at gmail.com
Tue Feb 15 07:35:20 PST 2022


I added this code to bin/lib/graphql.js, which is from the referenced
issue, but it failed. It's notable that my issue is slightly different
from the one posted. Below, the first request throws, and it
successfully downloads the transaction from the cache. However,
getUploader then fails, saying the transaction does not exist. I
wonder if there could have been a huge chain fork or something.

const apiCfg = arweave.getConfig().api;
const gatewayEndpoint = `${apiCfg.protocol}://${apiCfg.host}:${apiCfg.port}/`
const graphQlEndpoint = gatewayEndpoint + "graphql";

const fetchSafely = async (txid) => {	
  debug(`fetchSafely("${txid}")`);
  try {
    const response = await arweave.transactions.getData(txid, {
      decode: true,
      string: true
    });
    debug(`fetched ${response.length} characters`);
    return response;
  } catch {
    debug(`encountered error, checking gateway cache`);
    const { data } = await axios.get(gatewayEndpoint + txid, {
      responseType: 'arraybuffer'
    });
    debug(`fetched ${data.length} bytes from gateway cache, reuploading`);

    const uploader = await arweave.transactions.getUploader(txid, data);

    while (!uploader.isComplete){
      await uploader.uploadChunk();
      debug(`chunkUploaded:
${uploader.uploadedChunks}/${uploader.totalChunks}
%${uploader.pctComplete}`);
      debug(`lastResponseStats: ${uploader.lastResponseStats}`);
    }

    const response = data.toString('utf8');

    return response;
  }
}


More information about the cypherpunks mailing list