コード例 #1
0
ファイル: parser.cpp プロジェクト: lionzeye/rddblockparser
static void parseTX(
    const uint8_t *&p
)
{
    uint8_t *txHash = 0;
    const uint8_t *txStart = p;

    if(gNeedTXHash && !skip) {
        const uint8_t *txEnd = p;
        parseTX<true>(txEnd);
        txHash = allocHash256();
        sha256Twice(txHash, txStart, txEnd - txStart);
    }

    if(!skip) startTX(p, txHash);

        SKIP(uint32_t, version, p);

        parseInputs<skip>(p, txHash);

        if(gNeedTXHash && !skip)
            gTXMap[txHash] = p;

        parseOutputs<skip, false>(p, txHash);

        SKIP(uint32_t, lockTime, p);

    if(!skip) endTX(p);
}
コード例 #2
0
ファイル: sql.cpp プロジェクト: brishtiteveja/bitiodine
  virtual void endOutput(
    const uint8_t *p,
    uint64_t       value,
    const uint8_t *txHash,
    uint64_t       outputIndex,
    const uint8_t *outputScript,
    uint64_t       outputScriptSize
    ) {
    uint8_t address[40];

    address[0] = 'X';
    address[1] = 0;

    uint8_t   addrType[3];
    uint160_t pubKeyHash;
    int type = solveOutputScript(
      pubKeyHash.v,
      outputScript,
      outputScriptSize,
      addrType
      );

    if (likely(0 <= type)) {
      hash160ToAddr(
        address,
        pubKeyHash.v,
        false,
        addrType[0]
        );
    }

    if (blkID >= firstBlock) {
      fprintf(
        outputFile,
        "%" PRIu64 "|"
        "%s|"
        "%" PRIu64 "|"
        "%" PRIu64 "|"
        "%" PRIu32 "\n"
        ,
        outputID,
        address,
        value,
        txID,
        (uint32_t)outputIndex
        );
    }

    uint32_t oi = outputIndex;
    uint8_t *h  = allocHash256();
    memcpy(h, txHash, kSHA256ByteSize);

    uintptr_t ih  = reinterpret_cast<uintptr_t>(h);
    uint32_t *h32 = reinterpret_cast<uint32_t *>(ih);
    h32[0] ^= oi;

    outputMap[h] = outputID++;
  }
コード例 #3
0
ファイル: sql.cpp プロジェクト: Devba/blockparser
    virtual void endOutput(
        const uint8_t *p,
        uint64_t      value,
        const uint8_t *txHash,
        uint64_t      outputIndex,
        const uint8_t *outputScript,
        uint64_t      outputScriptSize
    )
    {
        uint8_t address[40];
        address[0] = 'X';
        address[1] = 0;

        uint8_t addrType[3];
        uint160_t pubKeyHash;
        int type = solveOutputScript(pubKeyHash.v, outputScript, outputScriptSize, addrType);
        if(likely(0<=type)) hash160ToAddr(address, pubKeyHash.v);

        // id BIGINT PRIMARY KEY
        // dstAddress CHAR(36)
        // value BIGINT
        // txID BIGINT
        // offset INT
        fprintf(
            outputFile,
            "%" PRIu64 "\t"
            "%s\t"
            "%" PRIu64 "\t"
            "%" PRIu64 "\t"
            "%" PRIu32 "\n"
            ,
            outputID,
            address,
            value,
            txID,
            (uint32_t)outputIndex
        );

        uint32_t oi = outputIndex;
        uint8_t *h = allocHash256();
        memcpy(h, txHash, kSHA256ByteSize);

        uintptr_t ih = reinterpret_cast<uintptr_t>(h);
        uint32_t *h32 = reinterpret_cast<uint32_t*>(ih);
        h32[0] ^= oi;

        outputMap[h] = outputID++;
    }
コード例 #4
0
ファイル: parser.cpp プロジェクト: martexcoin/blockparser
static void getBlockHeader(
    size_t        &size,
    Block        *&prev,
    uint8_t      *&hash,
    size_t        &earlyMissCnt,
    const uint8_t *p
) {

    LOAD(uint32_t, magic, p);
    if(unlikely(gExpectedMagic!=magic)) {
        hash = 0;
        return;
    }

    LOAD(uint32_t, sz, p);
    size = sz;
    prev = 0;

    hash = allocHash256();

    #if defined(DARKCOIN)
        h9(hash, p, gHeaderSize);
    #elif defined(PAYCON) 
        h13(hash, p, gHeaderSize);
    #elif defined(MARTEXCOIN)
        h13(hash, p, gHeaderSize);
    #elif defined(CLAM)
        auto pBis = p;
        LOAD(uint32_t, nVersion, pBis);
        if(6<nVersion) {
            sha256Twice(hash, p, gHeaderSize);
        } else {
            scrypt(hash, p, gHeaderSize);
        }
    #elif defined(JUMBUCKS)
        scrypt(hash, p, gHeaderSize);
    #else
        sha256Twice(hash, p, gHeaderSize);
    #endif

    auto i = gBlockMap.find(p + 4);
    if(likely(gBlockMap.end()!=i)) {
        prev = i->second;
    } else {
        ++earlyMissCnt;
    }
}
コード例 #5
0
ファイル: parser.cpp プロジェクト: husthub/blockparser
static bool buildBlock(
    const uint8_t *&p,
    const uint8_t *e
)
{
	//litcoin 0xfb, 0xc0, 0xb6, 0xdb
	//unsigned char pchMessageStart[4] = { 0xce, 0xfb, 0xfa, 0xdb };
    static const uint32_t expected =
    #if defined(UVCCOIN)
        0xdbfafbce
    #elif defined(LITECOIN)
        0xdbb6c0fb
    #else
        0xd9b4bef9
    #endif
    ;

    if(unlikely(e<=(8+p))) {
        //printf("end of map, reason : pointer past EOF\n");
        return true;
    }

    LOAD(uint32_t, magic, p);
    if(unlikely(expected!=magic)) {
        //printf("end of map, reason : magic is f****d %d away from EOF\n", (int)(e-p));
        return true;
    }

    LOAD(uint32_t, size, p);
    if(unlikely(e<(p+size))) {
        //printf("end of map, reason : end of block past EOF, %d past EOF\n", (int)((p+size)-e));
        return true;
    }

    Block *block = allocBlock();
    block->height = -1;
    block->data = p;
    block->prev = 0;
    block->next = 0;

    uint8_t *hash = allocHash256();
    sha256Twice(hash, p, 80);
    gBlockMap[hash] = block;
    p += size;
    return false;
}
コード例 #6
0
ファイル: parser.cpp プロジェクト: lionzeye/rddblockparser
static bool buildBlock(
    const uint8_t *&p,
    const uint8_t *e
)
{
    static const uint32_t expected =
    #if defined(REDDCOIN)
        0xdbb6c0fb
    #else
        0xd9b4bef9
    #endif
    ;

    if(unlikely(e<=(8+p))) {
        //printf("end of map, reason : pointer past EOF\n");
        return true;
    }

    LOAD(uint32_t, magic, p);
    if(unlikely(expected!=magic)) {
        //printf("end of map, reason : magic is f****d %d away from EOF\n", (int)(e-p));
        return true;
    }

    LOAD(uint32_t, size, p);
    if(unlikely(e<(p+size))) {
        //printf("end of map, reason : end of block past EOF, %d past EOF\n", (int)((p+size)-e));
        return true;
    }

    Block *block = allocBlock();
    block->height = -1;
    block->data = p;
    block->prev = 0;
    block->next = 0;

    uint8_t *hash = allocHash256();
    sha256Twice(hash, p, 80);
    gBlockMap[hash] = block;
    p += size;
    return false;
}
コード例 #7
0
ファイル: parser.cpp プロジェクト: jeorgen/blockparser
static void parseTX(
    const Block   *block,
    const uint8_t *&p
) {
    auto txStart = p;
    uint8_t *txHash = 0;

    if(gNeedTXHash && !skip) {
        auto txEnd = p;
        txHash = allocHash256();
        parseTX<true>(block, txEnd);
        sha256Twice(txHash, txStart, txEnd - txStart);
    }

    if(!skip) {
        startTX(p, txHash);
    }

        #if defined(CLAM)
            LOAD(uint32_t, nVersion, p);
        #else
            SKIP(uint32_t, nVersion, p);
        #endif

        #if defined(PEERCOIN) || defined(CLAM) || defined(JUMBUCKS)
            SKIP(uint32_t, nTime, p);
        #endif

        parseInputs<skip>(block, p, txHash);

        Chunk *txo = 0;
        size_t txoOffset = -1;
        const uint8_t *outputsStart = p;
        if(gNeedTXHash && !skip) {
            txo = Chunk::alloc();
            txoOffset = block->chunk->getOffset() + (p - block->chunk->getData());
            gTXOMap[txHash] = txo;
        }

        parseOutputs<skip, false>(p, txHash);

        if(txo) {
            size_t txoSize = p - outputsStart;
            txo->init(
                block->chunk->getMap(),
                txoSize,
                txoOffset
            );
        }

        SKIP(uint32_t, lockTime, p);

        #if defined(CLAM)
            if(1<nVersion) {
                LOAD_VARINT(strCLAMSpeechLen, p);
                p += strCLAMSpeechLen;
            }
        #endif

    if(!skip) {
        endTX(p);
    }
}