用于equihash solver的区块头格式是怎样的?


#1

我把区块头的前140个字节以小端拼接到char vector,发现不对…输入如下

void write(vector<char> &v, const char *beg, const unsigned int len)

{
v.insert(v.end(), beg, beg + len);
}

void init()
{
version = htole32(1);
hashPrevBlock.SetHex(“0”);
hashMerkleRoot.SetHex(“0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b”);
hashReserved.SetHex(“0”);
ntime = htole32(1231006505);
nbits = htole32(0x207fffff);
nonce.SetHex(“3”);
}

int main()
{
init();

//uint256::pTable();

file.open("input.bin", ios::out | ios::binary);
vector<char> ser;

// serialize header in little endian to ser
write(ser, (char*)&version, sizeof(version));
write(ser, hashPrevBlock.begin(), 32);
write(ser, hashMerkleRoot.begin(), 32);
write(ser, hashReserved.begin(), 32);
write(ser, (char*)&ntime, sizeof(ntime));
write(ser, (char*)&nbits, sizeof(nbits));
write(ser, nonce.begin(), 32);

//std::cout << ser.size() << std::endl;

for (vector<char>::iterator itr = ser.begin(); itr != ser.end(); ++itr)
{
    file << *itr;
}

file.close();

新手一枚,求助谢谢。