altcoin – After add some files , it shows undefined reference,how to solve it?

0
10


I am a newbie learning bitcoin source. I add a new POW function and add it to the source of bitcoin-0.20.But it shows below, I’m still thinking about it but get no solution indeed, would you please help me?

CXXLD    test/test_bitcoin
/usr/bin/ld: libbitcoin_common.a(libbitcoin_common_a-coins.o): in function `SaltedOutpointHasher::operator()(COutPoint const&) const':
/home/gilsun91/bitcoin-0.20/src/./coins.h:108: undefined reference to `SipHashUint256Extra(unsigned long, unsigned long, uint256 const&, unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:7584: bitcoin-tx] Error 1
make[2]: *** Waiting for unfinished jobs....
/usr/bin/ld: libbitcoin_common.a(libbitcoin_common_a-coins.o): in function `SaltedOutpointHasher::operator()(COutPoint const&) const':
/home/gilsun91/bitcoin-0.20/src/./coins.h:108: undefined reference to `SipHashUint256Extra(unsigned long, unsigned long, uint256 const&, unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:7588: bitcoin-wallet] Error 1
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::ConnectNode(CAddress, char const*, bool, bool, bool)':
/home/gilsun91/bitcoin-0.20/src/net.cpp:445: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:445: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::AcceptConnection(CConnman::ListenSocket const&)':
/home/gilsun91/bitcoin-0.20/src/net.cpp:1028: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:1028: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::GetDeterministicRandomizer(unsigned long) const':
/home/gilsun91/bitcoin-0.20/src/net.cpp:2821: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:2821: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::CalculateKeyedNetGroup(CAddress const&) const':
/home/gilsun91/bitcoin-0.20/src/net.cpp:2828: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:2828: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net_processing.o): in function `RelayAddress(CAddress const&, bool, CConnman const&)::{lambda(CNode*)#1}::operator()(CNode*) const':
/home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1396: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1396: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net_processing.o): in function `RelayAddress(CAddress const&, bool, CConnman const&)':
/home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1388: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1388: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net_processing.o): in function `SaltedTxidHasher::operator()(uint256 const&) const':
/home/gilsun91/bitcoin-0.20/src/./txmempool.h:367: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-txdb.o): in function `SaltedOutpointHasher::operator()(COutPoint const&) const':
/home/gilsun91/bitcoin-0.20/src/./coins.h:108: undefined reference to `SipHashUint256Extra(unsigned long, unsigned long, uint256 const&, unsigned int)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-blockencodings.o): in function `CBlockHeaderAndShortTxIDs::GetShortID(uint256 const&) const':
/home/gilsun91/bitcoin-0.20/src/blockencodings.cpp:44: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-blockfilter.o): in function `GCSFilter::HashToRange(std::vector<unsigned char, std::allocator<unsigned char> > const&) const':
/home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:90: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:91: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:92: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_util.a(libbitcoin_util_a-bytevectorhash.o): in function `ByteVectorHash::operator()(std::vector<unsigned char, std::allocator<unsigned char> > const&) const':
/home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::Finalize() const'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:7592: bitcoind] Error 1
/usr/bin/ld: test/test_bitcoin-blockencodings_tests.o: in function `SaltedTxidHasher::operator()(uint256 const&) const':
/home/gilsun91/bitcoin-0.20/src/./txmempool.h:367: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: test/test_bitcoin-coins_tests.o: in function `SaltedOutpointHasher::operator()(COutPoint const&) const':
/home/gilsun91/bitcoin-0.20/src/./coins.h:108: undefined reference to `SipHashUint256Extra(unsigned long, unsigned long, uint256 const&, unsigned int)'
/usr/bin/ld: test/test_bitcoin-crypto_tests.o: in function `crypto_tests::TestPoly1305(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:169: undefined reference to `poly1305_auth(unsigned char*, unsigned char const*, unsigned long, unsigned char const*)'
/usr/bin/ld: test/test_bitcoin-crypto_tests.o: in function `crypto_tests::TestHKDF_SHA256_32(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:183: undefined reference to `CHKDF_HMAC_SHA256_L32::CHKDF_HMAC_SHA256_L32(unsigned char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:185: undefined reference to `CHKDF_HMAC_SHA256_L32::Expand32(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)'
/usr/bin/ld: test/test_bitcoin-crypto_tests.o: in function `crypto_tests::TestChaCha20Poly1305AEAD(bool, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:614: undefined reference to `ChaCha20Poly1305AEAD::ChaCha20Poly1305AEAD(unsigned char const*, unsigned long, unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:620: undefined reference to `ChaCha20Poly1305AEAD::Crypt(unsigned long, unsigned long, int, unsigned char*, unsigned long, unsigned char const*, unsigned long, bool)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:643: undefined reference to `ChaCha20Poly1305AEAD::Crypt(unsigned long, unsigned long, int, unsigned char*, unsigned long, unsigned char const*, unsigned long, bool)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:645: undefined reference to `ChaCha20Poly1305AEAD::GetLength(unsigned int*, unsigned long, int, unsigned char const*)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/crypto_tests.cpp:647: undefined reference to `ChaCha20Poly1305AEAD::Crypt(unsigned long, unsigned long, int, unsigned char*, unsigned long, unsigned char const*, unsigned long, bool)'
/usr/bin/ld: test/test_bitcoin-hash_tests.o: in function `hash_tests::siphash::test_method()':
/home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:82: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:83: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:85: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:86: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:88: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:89: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:90: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:91: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:93: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:94: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:96: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:97: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:99: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:100: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:101: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:102: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:103: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:104: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:106: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:109: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:112: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:113: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:116: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:119: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:121: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:130: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:141: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:142: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:144: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:145: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:145: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:146: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/test/hash_tests.cpp:146: undefined reference to `SipHashUint256Extra(unsigned long, unsigned long, uint256 const&, unsigned int)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-blockencodings.o): in function `CBlockHeaderAndShortTxIDs::GetShortID(uint256 const&) const':
/home/gilsun91/bitcoin-0.20/src/blockencodings.cpp:44: undefined reference to `SipHashUint256(unsigned long, unsigned long, uint256 const&)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-blockfilter.o): in function `GCSFilter::HashToRange(std::vector<unsigned char, std::allocator<unsigned char> > const&) const':
/home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:90: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:91: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/blockfilter.cpp:92: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::ConnectNode(CAddress, char const*, bool, bool, bool)':
/home/gilsun91/bitcoin-0.20/src/net.cpp:445: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:445: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::AcceptConnection(CConnman::ListenSocket const&)':
/home/gilsun91/bitcoin-0.20/src/net.cpp:1028: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:1028: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::GetDeterministicRandomizer(unsigned long) const':
/home/gilsun91/bitcoin-0.20/src/net.cpp:2821: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:2821: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net.o): in function `CConnman::CalculateKeyedNetGroup(CAddress const&) const':
/home/gilsun91/bitcoin-0.20/src/net.cpp:2828: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net.cpp:2828: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net_processing.o): in function `RelayAddress(CAddress const&, bool, CConnman const&)::{lambda(CNode*)#1}::operator()(CNode*) const':
/home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1396: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1396: undefined reference to `CSipHasher::Finalize() const'
/usr/bin/ld: libbitcoin_server.a(libbitcoin_server_a-net_processing.o): in function `RelayAddress(CAddress const&, bool, CConnman const&)':
/home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1388: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/net_processing.cpp:1388: undefined reference to `CSipHasher::Write(unsigned long)'
/usr/bin/ld: libbitcoin_util.a(libbitcoin_util_a-bytevectorhash.o): in function `ByteVectorHash::operator()(std::vector<unsigned char, std::allocator<unsigned char> > const&) const':
/home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::CSipHasher(unsigned long, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::Write(unsigned char const*, unsigned long)'
/usr/bin/ld: /home/gilsun91/bitcoin-0.20/src/util/bytevectorhash.cpp:17: undefined reference to `CSipHasher::Finalize() const'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:8551: test/test_bitcoin] Error 1
make[2]: Leaving directory '/home/gilsun91/bitcoin-0.20/src'
make[1]: *** [Makefile:17887: all-recursive] Error 1
make[1]: Leaving directory '/home/gilsun91/bitcoin-0.20/src'
make: *** [Makefile:781: all-recursive] Error 1

in src/Makefile.am , I add some contents below:

366 # crypto primitives library
367 crypto_libbitcoin_crypto_base_a_CPPFLAGS = $(AM_CPPFLAGS)
368 crypto_libbitcoin_crypto_base_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
369 crypto_libbitcoin_crypto_base_a_SOURCES = 
370   crypto/aes.cpp 
371   crypto/aes.h 
372   crypto/chacha_poly_aead.h 
373   crypto/chacha_poly_aead.cpp 
374   crypto/chacha20.h 
375   crypto/chacha20.cpp 
376   crypto/common.h 
377   crypto/hkdf_sha256_32.cpp 
378   crypto/hkdf_sha256_32.h 
379   crypto/hmac_sha256.cpp 
380   crypto/hmac_sha256.h 
381   crypto/hmac_sha512.cpp 
382   crypto/hmac_sha512.h 
383   crypto/poly1305.h 
384   crypto/poly1305.cpp 
385   crypto/ripemd160.cpp 
386   crypto/ripemd160.h 
387   crypto/sha1.cpp 
388   crypto/sha1.h 
389   crypto/sha256.cpp 
390   crypto/sha256.h 
391   crypto/sha512.cpp 
392   crypto/sha512.h 
393   crypto/siphash.cpp 
394   crypto/siphash.h 
395   crypto/x13hash/aes_helper.c 
396   crypto/x13hash/blake.c  
397   crypto/x13hash/bmw.c  
398   crypto/x13hash/cubehash.c  
399   crypto/x13hash/echo.c  
400   crypto/x13hash/fugue.c  
401   crypto/x13hash/groestl.c  
402   crypto/x13hash/hamsi_helper.c  
403   crypto/x13hash/hamsi.c  
404   crypto/x13hash/jh.c  
405   crypto/x13hash/keccak.c  
406   crypto/x13hash/luffa.c  
407   crypto/x13hash/shavite.c  
408   crypto/x13hash/simd.c  
409   crypto/x13hash/skein.c  
410   crypto/x13hash/sm3.c  
411   crypto/x13hash/sph_blake.h  
412   crypto/x13hash/sph_bmw.h  
413   crypto/x13hash/sph_cubehash.h  
414   crypto/x13hash/sph_echo.h  
415   crypto/x13hash/sph_fugue.h  
416   crypto/x13hash/sph_groestl.h  
417   crypto/x13hash/sph_hamsi.h  
418   crypto/x13hash/sph_jh.h  
419   crypto/x13hash/sph_keccak.h  
420   crypto/x13hash/sph_luffa.h  
421   crypto/x13hash/sph_shavite.h  
422   crypto/x13hash/sph_simd.h  
423   crypto/x13hash/sph_skein.h  
424   crypto/x13hash/sph_sm3.h  
425   crypto/x13hash/sph_types.h

I add a new function in block.h below

class CBlockHeader
{
public:
    // header
    int32_t nVersion;
    uint256 hashPrevBlock;
    uint256 hashMerkleRoot;
    uint32_t nTime;
    uint32_t nBits;
    uint32_t nNonce;

    CBlockHeader()
    {
        SetNull();
    }

    ADD_SERIALIZE_METHODS;

    template <typename Stream, typename Operation>
    inline void SerializationOp(Stream& s, Operation ser_action) {
        READWRITE(this->nVersion);
        READWRITE(hashPrevBlock);
        READWRITE(hashMerkleRoot);
        READWRITE(nTime);
        READWRITE(nBits);
        READWRITE(nNonce);
    }

    void SetNull()
    {
        nVersion = 0;
        hashPrevBlock.SetNull();
        hashMerkleRoot.SetNull();
        nTime = 0;
        nBits = 0;
        nNonce = 0;
    }

    bool IsNull() const
    {
        return (nBits == 0);
    }

    uint256 GetHash() const;
    uint256 GetNewPoWHash() const; //new hash function

    int64_t GetBlockTime() const
    {
        return (int64_t)nTime;
    }
};

3, add the function in block.cpp

#include <hash.h>
#include <tinyformat.h>

#define BEGIN(a)            ((char*)&(a))
#define END(a)              ((char*)&((&(a))[1]))
#define UBEGIN(a)           ((unsigned char*)&(a))
#define UEND(a)             ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array)     (sizeof(array)/sizeof((array)[0]))

uint256 CBlockHeader::GetHash() const
{
    return SerializeHash(*this);
}
uint256 CBlockHeader::GetNewPoWHash() const //new !! 
{   
    return HashX13sm3(BEGIN(nVersion), END(nNonce));
}

and rpc/mining.cpp:127: while (nMaxTries > 0 && pblock->nNonce < std::numeric_limits<uint32_t>::max() && !CheckProofOfWork(pblock->GetNewPoWHash(), pblock->nBits, Params().GetConsensus()) && !ShutdownRequested()) {
So ,how to solve it? Thank you very much.



Source link

Leave a reply