From 135dad4f3ca627b22dde498847480b3410c5bd12 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 10:42:21 +0800 Subject: [PATCH 01/38] fix codes in order to support openssl 1.1 --- libraries/fc/include/fc/crypto/elliptic.hpp | 16 -- libraries/fc/src/crypto/base58.cpp | 142 +++++++------ libraries/fc/src/crypto/dh.cpp | 46 +++- libraries/fc/src/crypto/elliptic_common.cpp | 11 +- .../fc/src/crypto/elliptic_secp256k1.cpp | 196 +----------------- libraries/fc/src/log/file_appender.cpp | 1 + 6 files changed, 126 insertions(+), 286 deletions(-) diff --git a/libraries/fc/include/fc/crypto/elliptic.hpp b/libraries/fc/include/fc/crypto/elliptic.hpp index 7d3046f2..924e1493 100644 --- a/libraries/fc/include/fc/crypto/elliptic.hpp +++ b/libraries/fc/include/fc/crypto/elliptic.hpp @@ -25,8 +25,6 @@ namespace fc { typedef fc::array compact_signature; typedef std::vector range_proof_type; typedef fc::array extended_key_data; - typedef fc::sha256 blinded_hash; - typedef fc::sha256 blind_signature; /** * @class public_key @@ -164,8 +162,6 @@ namespace fc { fc::string to_base58() const { return str(); } static extended_public_key from_base58( const fc::string& base58 ); - public_key generate_p( int i ) const; - public_key generate_q( int i ) const; private: sha256 c; int child_num, parent_fp; @@ -194,23 +190,11 @@ namespace fc { // Oleg Andreev's blind signature scheme, // see http://blog.oleganza.com/post/77474860538/blind-signatures - public_key blind_public_key( const extended_public_key& bob, int i ) const; - blinded_hash blind_hash( const fc::sha256& hash, int i ) const; - blind_signature blind_sign( const blinded_hash& hash, int i ) const; // WARNING! This may produce non-canonical signatures! - compact_signature unblind_signature( const extended_public_key& bob, - const blind_signature& sig, - const fc::sha256& hash, int i ) const; private: extended_private_key private_derive_rest( const fc::sha512& hash, int num ) const; - private_key generate_a( int i ) const; - private_key generate_b( int i ) const; - private_key generate_c( int i ) const; - private_key generate_d( int i ) const; - private_key_secret compute_p( int i ) const; - private_key_secret compute_q( int i, const private_key_secret& p ) const; sha256 c; int child_num, parent_fp; uint8_t depth; diff --git a/libraries/fc/src/crypto/base58.cpp b/libraries/fc/src/crypto/base58.cpp index e1d5d333..5c7f371a 100644 --- a/libraries/fc/src/crypto/base58.cpp +++ b/libraries/fc/src/crypto/base58.cpp @@ -66,74 +66,73 @@ class CAutoBN_CTX /** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum : public BIGNUM +class CBigNum { + BIGNUM* bn; public: CBigNum() - { - BN_init(this); - } + : bn(BN_new()) {} CBigNum(const CBigNum& b) + : CBigNum() { - BN_init(this); - if (!BN_copy(this, &b)) + if (!BN_copy(bn, b.bn)) { - BN_clear_free(this); + BN_clear_free(bn); throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); } } CBigNum& operator=(const CBigNum& b) { - if (!BN_copy(this, &b)) + if (!BN_copy(bn, b.bn)) throw bignum_error("CBigNum::operator= : BN_copy failed"); return (*this); } ~CBigNum() { - BN_clear_free(this); + BN_clear_free(bn); } //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(signed char n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } //CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int64_t n) { BN_init(this); setint64(n); } - CBigNum(unsigned char n) { BN_init(this); setulong(n); } - CBigNum(unsigned short n) { BN_init(this); setulong(n); } - CBigNum(unsigned int n) { BN_init(this); setulong(n); } + CBigNum(int64_t n) :CBigNum() { setint64(n); } + CBigNum(unsigned char n) :CBigNum() { setulong(n); } + CBigNum(unsigned short n) :CBigNum() { setulong(n); } + CBigNum(unsigned int n) :CBigNum() { setulong(n); } //CBigNum(unsigned long n) { BN_init(this); setulong(n); } - CBigNum(uint64_t n) { BN_init(this); setuint64(n); } + CBigNum(uint64_t n) :CBigNum() { setuint64(n); } explicit CBigNum(const std::vector& vch) + : CBigNum() { - BN_init(this); setvch(vch); } void setulong(unsigned long n) { - if (!BN_set_word(this, n)) + if (!BN_set_word(bn, n)) throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); } unsigned long getulong() const { - return BN_get_word(this); + return BN_get_word(bn); } unsigned int getuint() const { - return BN_get_word(this); + return BN_get_word(bn); } int getint() const { - unsigned long n = BN_get_word(this); - if (!BN_is_negative(this)) + unsigned long n = BN_get_word(bn); + if (!BN_is_negative(bn)) return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); @@ -171,7 +170,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } void setuint64(uint64_t n) @@ -198,7 +197,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } @@ -214,16 +213,16 @@ class CBigNum : public BIGNUM vch2[3] = (nSize >> 0) & 0xff; // swap data to big endian reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), this); + BN_mpi2bn(&vch2[0], vch2.size(), bn); } std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); if (nSize <= 4) return std::vector(); std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); return vch; @@ -237,16 +236,16 @@ class CBigNum : public BIGNUM if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff; - BN_mpi2bn(&vch[0], vch.size(), this); + BN_mpi2bn(&vch[0], vch.size(), bn); return *this; } unsigned int GetCompact() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); std::vector vch(nSize); nSize -= 4; - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); unsigned int nCompact = nSize << 24; if (nSize >= 1) nCompact |= (vch[4] << 16); if (nSize >= 2) nCompact |= (vch[5] << 8); @@ -281,7 +280,7 @@ class CBigNum : public BIGNUM *this += n; } if (fNegative) - *this = 0 - *this; + BN_set_negative(bn, 1); } std::string ToString(int nBase=10) const @@ -291,20 +290,20 @@ class CBigNum : public BIGNUM CBigNum bn0 = 0; std::string str; CBigNum bn = *this; - BN_set_negative(&bn, false); + BN_set_negative(bn.bn, false); CBigNum dv; CBigNum rem; - if (BN_cmp(&bn, &bn0) == 0) + if (BN_cmp(bn.bn, bn0.bn) == 0) return "0"; - while (BN_cmp(&bn, &bn0) > 0) + while (BN_cmp(bn.bn, bn0.bn) > 0) { - if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) + if (!BN_div(dv.bn, rem.bn, bn.bn, bnBase.bn, pctx)) throw bignum_error("CBigNum::ToString() : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } - if (BN_is_negative(this)) + if (BN_is_negative(this->bn)) str += "-"; reverse(str.begin(), str.end()); return str; @@ -319,45 +318,50 @@ class CBigNum : public BIGNUM bool operator!() const { - return BN_is_zero(this); + return BN_is_zero(bn); } CBigNum& operator+=(const CBigNum& b) { - if (!BN_add(this, this, &b)) + if (!BN_add(bn, bn, b.bn)) throw bignum_error("CBigNum::operator+= : BN_add failed"); return *this; } CBigNum& operator-=(const CBigNum& b) { - *this = *this - b; + if (!BN_sub(bn, bn, b.bn)) + throw bignum_error("CBigNum::operator-= : BN_sub failed"); return *this; } CBigNum& operator*=(const CBigNum& b) { CAutoBN_CTX pctx; - if (!BN_mul(this, this, &b, pctx)) + if (!BN_mul(bn, bn, b.bn, pctx)) throw bignum_error("CBigNum::operator*= : BN_mul failed"); return *this; } CBigNum& operator/=(const CBigNum& b) { - *this = *this / b; + CAutoBN_CTX pctx; + if (!BN_div(bn, NULL, bn, b.bn, pctx)) + throw bignum_error("CBigNum::operator/= : BN_div failed"); return *this; } CBigNum& operator%=(const CBigNum& b) { - *this = *this % b; + CAutoBN_CTX pctx; + if (!BN_div(NULL, bn, bn, b.bn, pctx)) + throw bignum_error("CBigNum::operator%= : BN_div failed"); return *this; } CBigNum& operator<<=(unsigned int shift) { - if (!BN_lshift(this, this, shift)) + if (!BN_lshift(bn, bn, shift)) throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); return *this; } @@ -368,13 +372,13 @@ class CBigNum : public BIGNUM // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl CBigNum a = 1; a <<= shift; - if (BN_cmp(&a, this) > 0) + if (BN_cmp(a.bn, bn) > 0) { *this = 0; return *this; } - if (!BN_rshift(this, this, shift)) + if (!BN_rshift(bn, bn, shift)) throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); return *this; } @@ -383,7 +387,7 @@ class CBigNum : public BIGNUM CBigNum& operator++() { // prefix operator - if (!BN_add(this, this, BN_value_one())) + if (!BN_add(bn, bn, BN_value_one())) throw bignum_error("CBigNum::operator++ : BN_add failed"); return *this; } @@ -400,7 +404,7 @@ class CBigNum : public BIGNUM { // prefix operator CBigNum r; - if (!BN_sub(&r, this, BN_value_one())) + if (!BN_sub(r.bn, bn, BN_value_one())) throw bignum_error("CBigNum::operator-- : BN_sub failed"); *this = r; return *this; @@ -414,10 +418,12 @@ class CBigNum : public BIGNUM return ret; } - - friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b); + const BIGNUM* to_bignum() const { + return bn; + } + BIGNUM* to_bignum() { + return bn; + } }; @@ -425,7 +431,7 @@ class CBigNum : public BIGNUM inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_add(&r, &a, &b)) + if (!BN_add(r.to_bignum(), a.to_bignum(), b.to_bignum())) throw bignum_error("CBigNum::operator+ : BN_add failed"); return r; } @@ -433,7 +439,7 @@ inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_sub(&r, &a, &b)) + if (!BN_sub(r.to_bignum(), a.to_bignum(), b.to_bignum())) throw bignum_error("CBigNum::operator- : BN_sub failed"); return r; } @@ -441,7 +447,7 @@ inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a) { CBigNum r(a); - BN_set_negative(&r, !BN_is_negative(&r)); + BN_set_negative(r.to_bignum(), !BN_is_negative(r.to_bignum())); return r; } @@ -449,7 +455,7 @@ inline const CBigNum operator*(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mul(&r, &a, &b, pctx)) + if (!BN_mul(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator* : BN_mul failed"); return r; } @@ -458,7 +464,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_div(&r, NULL, &a, &b, pctx)) + if (!BN_div(r.to_bignum(), NULL, a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator/ : BN_div failed"); return r; } @@ -467,7 +473,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mod(&r, &a, &b, pctx)) + if (!BN_mod(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator% : BN_div failed"); return r; } @@ -475,7 +481,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) inline const CBigNum operator<<(const CBigNum& a, unsigned int shift) { CBigNum r; - if (!BN_lshift(&r, &a, shift)) + if (!BN_lshift(r.to_bignum(), a.to_bignum(), shift)) throw bignum_error("CBigNum:operator<< : BN_lshift failed"); return r; } @@ -487,12 +493,12 @@ inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) return r; } -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); } +inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) == 0); } +inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) != 0); } +inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) <= 0); } +inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) >= 0); } +inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) < 0); } +inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) > 0); } static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; @@ -522,7 +528,7 @@ inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char CBigNum rem; while (bn > bn0) { - if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) + if (!BN_div(dv.to_bignum(), rem.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) throw bignum_error("EncodeBase58 : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); @@ -572,7 +578,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) break; } bnChar.setulong(p1 - pszBase58); - if (!BN_mul(&bn, &bn, &bn58, pctx)) + if (!BN_mul(bn.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; } @@ -632,7 +638,9 @@ size_t from_base58( const std::string& base58_str, char* out_data, size_t out_da FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) ); } FC_ASSERT( out.size() <= out_data_len ); + if (!out.empty()) { memcpy( out_data, out.data(), out.size() ); + } return out.size(); } } diff --git a/libraries/fc/src/crypto/dh.cpp b/libraries/fc/src/crypto/dh.cpp index cbd7dcc2..de2beeb5 100644 --- a/libraries/fc/src/crypto/dh.cpp +++ b/libraries/fc/src/crypto/dh.cpp @@ -1,6 +1,8 @@ #include #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#endif namespace fc { SSL_TYPE(ssl_dh, DH, DH_free) @@ -12,10 +14,19 @@ namespace fc { bool diffie_hellman::generate_params( int s, uint8_t g ) { - ssl_dh dh = DH_generate_parameters( s, g, NULL, NULL ); + ssl_dh dh(DH_new()); + DH_generate_parameters_ex(dh.obj, s, g, NULL); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const BIGNUM* bn_p; // must not be free'd! + DH_get0_pqg(dh.obj, &bn_p, NULL, NULL); + p.resize( BN_num_bytes( bn_p ) ); + if( p.size() ) + BN_bn2bin( bn_p, (unsigned char*)&p.front() ); +#else p.resize( BN_num_bytes( dh->p ) ); if( p.size() ) BN_bn2bin( dh->p, (unsigned char*)&p.front() ); +#endif this->g = g; return fc::validate( dh, valid ); } @@ -25,8 +36,14 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif return fc::validate( dh, valid ); } @@ -35,8 +52,14 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif if( !fc::validate( dh, valid ) ) { @@ -44,21 +67,42 @@ namespace fc { } DH_generate_key(dh); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const BIGNUM* bn_pub_key; // must not be free'd! + const BIGNUM* bn_priv_key; // must not be free'd! + DH_get0_key(dh.obj, &bn_pub_key, &bn_priv_key); + pub_key.resize( BN_num_bytes( bn_pub_key ) ); + priv_key.resize( BN_num_bytes( bn_priv_key ) ); + if( pub_key.size() ) + BN_bn2bin( bn_pub_key, (unsigned char*)&pub_key.front() ); + if( priv_key.size() ) + BN_bn2bin( bn_priv_key, (unsigned char*)&priv_key.front() ); +#else pub_key.resize( BN_num_bytes( dh->pub_key ) ); priv_key.resize( BN_num_bytes( dh->priv_key ) ); if( pub_key.size() ) BN_bn2bin( dh->pub_key, (unsigned char*)&pub_key.front() ); if( priv_key.size() ) BN_bn2bin( dh->priv_key, (unsigned char*)&priv_key.front() ); +#endif return true; } bool diffie_hellman::compute_shared_key( const char* buf, uint32_t s ) { ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + auto bn_pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); + auto bn_priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); + auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); + DH_set0_key(dh.obj, bn_pub_key, bn_priv_key); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); dh->priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif int check; DH_check(dh,&check); diff --git a/libraries/fc/src/crypto/elliptic_common.cpp b/libraries/fc/src/crypto/elliptic_common.cpp index 66b75d09..ed4cc559 100644 --- a/libraries/fc/src/crypto/elliptic_common.cpp +++ b/libraries/fc/src/crypto/elliptic_common.cpp @@ -231,11 +231,12 @@ namespace fc { namespace ecc { static fc::string _to_base58( const extended_key_data& key ) { - char *buffer = (char*)alloca(key.size() + 4); + size_t buf_len = key.size() + 4; + char *buffer = (char*)alloca(buf_len); memcpy( buffer, key.begin(), key.size() ); fc::sha256 double_hash = fc::sha256::hash( fc::sha256::hash( key.begin(), key.size() )); memcpy( buffer + key.size(), double_hash.data(), 4 ); - return fc::to_base58( buffer, sizeof(buffer) ); + return fc::to_base58( buffer, buf_len ); } static void _parse_extended_data( unsigned char* buffer, fc::string base58 ) @@ -301,8 +302,6 @@ namespace fc { namespace ecc { return extended_public_key( get_public_key(), c, child_num, parent_fp, depth ); } - public_key extended_public_key::generate_p(int i) const { return derive_normal_child(2*i + 0); } - public_key extended_public_key::generate_q(int i) const { return derive_normal_child(2*i + 1); } extended_private_key extended_private_key::derive_child(int i) const { @@ -346,10 +345,6 @@ namespace fc { namespace ecc { return from_base58( _to_base58( data ) ); } - private_key extended_private_key::generate_a(int i) const { return derive_hardened_child(4*i + 0); } - private_key extended_private_key::generate_b(int i) const { return derive_hardened_child(4*i + 1); } - private_key extended_private_key::generate_c(int i) const { return derive_hardened_child(4*i + 2); } - private_key extended_private_key::generate_d(int i) const { return derive_hardened_child(4*i + 3); } fc::string extended_private_key::str() const { diff --git a/libraries/fc/src/crypto/elliptic_secp256k1.cpp b/libraries/fc/src/crypto/elliptic_secp256k1.cpp index 91edc18d..63d1fbbe 100644 --- a/libraries/fc/src/crypto/elliptic_secp256k1.cpp +++ b/libraries/fc/src/crypto/elliptic_secp256k1.cpp @@ -185,82 +185,12 @@ namespace fc { namespace ecc { return result; } - static void to_bignum( const unsigned char* in, ssl_bignum& out, unsigned int len ) - { - if ( *in & 0x80 ) - { - unsigned char *buffer = (unsigned char*)alloca(len + 1); - *buffer = 0; - memcpy( buffer + 1, in, len ); - BN_bin2bn( buffer, sizeof(buffer), out ); - } - else - { - BN_bin2bn( in, len, out ); - } - } - static void to_bignum( const private_key_secret& in, ssl_bignum& out ) - { - to_bignum( (unsigned char*) in.data(), out, in.data_size() ); - } - static void from_bignum( const ssl_bignum& in, unsigned char* out, unsigned int len ) - { - unsigned int l = BN_num_bytes( in ); - if ( l > len ) - { - unsigned char *buffer = (unsigned char*)alloca(l); - BN_bn2bin( in, buffer ); - memcpy( out, buffer + l - len, len ); - } - else - { - memset( out, 0, len - l ); - BN_bn2bin( in, out + len - l ); - } - } - static void from_bignum( const ssl_bignum& in, private_key_secret& out ) - { - from_bignum( in, (unsigned char*) out.data(), out.data_size() ); - } - static void invert( const private_key_secret& in, private_key_secret& out ) - { - ssl_bignum bn_in; - to_bignum( in, bn_in ); - ssl_bignum bn_n; - to_bignum( detail::get_curve_order(), bn_n ); - ssl_bignum bn_inv; - bn_ctx ctx( BN_CTX_new() ); - FC_ASSERT( BN_mod_inverse( bn_inv, bn_in, bn_n, ctx ) ); - from_bignum( bn_inv, out ); - } - static void to_point( const public_key_data& in, ec_point& out ) - { - bn_ctx ctx( BN_CTX_new() ); - const ec_group& curve = detail::get_curve(); - private_key_secret x; - memcpy( x.data(), in.begin() + 1, x.data_size() ); - ssl_bignum bn_x; - to_bignum( x, bn_x ); - FC_ASSERT( EC_POINT_set_compressed_coordinates_GFp( curve, out, bn_x, *in.begin() & 1, ctx ) > 0 ); - } - static void from_point( const ec_point& in, public_key_data& out ) - { - bn_ctx ctx( BN_CTX_new() ); - const ec_group& curve = detail::get_curve(); - ssl_bignum bn_x; - ssl_bignum bn_y; - FC_ASSERT( EC_POINT_get_affine_coordinates_GFp( curve, in, bn_x, bn_y, ctx ) > 0 ); - private_key_secret x; - from_bignum( bn_x, x ); - memcpy( out.begin() + 1, x.data(), out.size() - 1 ); - *out.begin() = BN_is_bit_set( bn_y, 0 ) ? 3 : 2; - } // static void print(const unsigned char* data) { // for (int i = 0; i < 32; i++) { @@ -276,72 +206,24 @@ namespace fc { namespace ecc { // print((unsigned char*) key.begin() + 1); // } - static void canonicalize( unsigned char *int256 ) - { - fc::sha256 biggi( (char*) int256, 32 ); - if ( detail::get_half_curve_order() >= biggi ) - { - return; // nothing to do - } - ssl_bignum bn_k; - to_bignum( int256, bn_k, 32 ); - ssl_bignum bn_n; - to_bignum( detail::get_curve_order(), bn_n ); - FC_ASSERT( BN_sub( bn_k, bn_n, bn_k ) ); - from_bignum( bn_k, int256, 32 ); - } - static public_key compute_k( const private_key_secret& a, const private_key_secret& c, - const public_key& p ) - { - private_key_secret prod = a; - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) prod.data(), (unsigned char*) c.data() ) > 0 ); - invert( prod, prod ); - public_key_data P = p.serialize(); - FC_ASSERT( secp256k1_ec_pubkey_tweak_mul( detail::_get_context(), (unsigned char*) P.begin(), P.size(), (unsigned char*) prod.data() ) ); // printf("K: "); print(P); printf("\n"); - return public_key( P ); - } - static public_key compute_t( const private_key_secret& a, const private_key_secret& b, - const private_key_secret& c, const private_key_secret& d, - const public_key_data& p, const public_key_data& q ) - { - private_key_secret prod; - invert( c, prod ); // prod == c^-1 - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) prod.data(), (unsigned char*) d.data() ) > 0 ); // prod == c^-1 * d - public_key_data accu = p; - FC_ASSERT( secp256k1_ec_pubkey_tweak_mul( detail::_get_context(), (unsigned char*) accu.begin(), accu.size(), (unsigned char*) prod.data() ) ); // accu == prod * P == c^-1 * d * P - ec_point point_accu( EC_POINT_new( detail::get_curve() ) ); - to_point( accu, point_accu ); - ec_point point_q( EC_POINT_new( detail::get_curve() ) ); - to_point( q, point_q ); - bn_ctx ctx(BN_CTX_new()); - FC_ASSERT( EC_POINT_add( detail::get_curve(), point_accu, point_accu, point_q, ctx ) > 0 ); - from_point( point_accu, accu ); // accu == c^-1 * a * P + Q - FC_ASSERT( secp256k1_ec_pubkey_tweak_add( detail::_get_context(), (unsigned char*) accu.begin(), accu.size(), (unsigned char*) b.data() ) ); // accu == c^-1 * a * P + Q + b*G - public_key_data k = compute_k( a, c, p ).serialize(); - memcpy( prod.data(), k.begin() + 1, prod.data_size() ); // prod == Kx - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) prod.data(), (unsigned char*) a.data() ) > 0 ); // prod == Kx * a - invert( prod, prod ); // prod == (Kx * a)^-1 - FC_ASSERT( secp256k1_ec_pubkey_tweak_mul( detail::_get_context(), (unsigned char*) accu.begin(), accu.size(), (unsigned char*) prod.data() ) ); // accu == (c^-1 * a * P + Q + b*G) * (Kx * a)^-1 // printf("T: "); print(accu); printf("\n"); - return public_key( accu ); - } extended_private_key::extended_private_key( const private_key& k, const sha256& c, int child, int parent, uint8_t depth ) @@ -356,102 +238,28 @@ namespace fc { namespace ecc { extended_private_key result( private_key::regenerate( left ), detail::_right(hash), i, fingerprint(), depth + 1 ); return result; - } - public_key extended_private_key::blind_public_key( const extended_public_key& bob, int i ) const - { - private_key_secret a = generate_a(i).get_secret(); - private_key_secret b = generate_b(i).get_secret(); - private_key_secret c = generate_c(i).get_secret(); - private_key_secret d = generate_d(i).get_secret(); - public_key_data p = bob.generate_p(i).serialize(); - public_key_data q = bob.generate_q(i).serialize(); // printf("a: "); print(a); printf("\n"); // printf("b: "); print(b); printf("\n"); // printf("c: "); print(c); printf("\n"); // printf("d: "); print(d); printf("\n"); // printf("P: "); print(p); printf("\n"); // printf("Q: "); print(q); printf("\n"); - return compute_t( a, b, c, d, p, q ); - } - blinded_hash extended_private_key::blind_hash( const fc::sha256& hash, int i ) const - { - private_key_secret a = generate_a(i).get_secret(); - private_key_secret b = generate_b(i).get_secret(); - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) a.data(), (unsigned char*) hash.data() ) > 0 ); - FC_ASSERT( secp256k1_ec_privkey_tweak_add( detail::_get_context(), (unsigned char*) a.data(), (unsigned char*) b.data() ) > 0 ); // printf("hash: "); print(hash); printf("\n"); // printf("blinded: "); print(a); printf("\n"); - return a; - } - private_key_secret extended_private_key::compute_p( int i ) const - { - private_key_secret p_inv = derive_normal_child( 2*i ).get_secret(); - invert( p_inv, p_inv ); // printf("p: "); print(p_inv); printf("\n"); - return p_inv; - } - private_key_secret extended_private_key::compute_q( int i, const private_key_secret& p ) const - { - private_key_secret q = derive_normal_child( 2*i + 1 ).get_secret(); - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) q.data(), (unsigned char*) p.data() ) > 0 ); // printf("q: "); print(q); printf("\n"); - return q; - } - blind_signature extended_private_key::blind_sign( const blinded_hash& hash, int i ) const - { - private_key_secret p = compute_p( i ); - private_key_secret q = compute_q( i, p ); - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) p.data(), (unsigned char*) hash.data() ) > 0 ); - FC_ASSERT( secp256k1_ec_privkey_tweak_add( detail::_get_context(), (unsigned char*) p.data(), (unsigned char*) q.data() ) > 0 ); // printf("blind_sig: "); print(p); printf("\n"); - return p; - } - compact_signature extended_private_key::unblind_signature( const extended_public_key& bob, - const blind_signature& sig, - const fc::sha256& hash, - int i ) const - { - private_key_secret a = generate_a(i).get_secret(); - private_key_secret b = generate_b(i).get_secret(); - private_key_secret c = generate_c(i).get_secret(); - private_key_secret d = generate_d(i).get_secret(); - public_key p = bob.generate_p(i); - public_key q = bob.generate_q(i); - public_key_data k = compute_k( a, c, p ); - public_key_data t = compute_t( a, b, c, d, p, q ).serialize(); - - FC_ASSERT( secp256k1_ec_privkey_tweak_mul( detail::_get_context(), (unsigned char*) c.data(), (unsigned char*) sig.data() ) > 0 ); - FC_ASSERT( secp256k1_ec_privkey_tweak_add( detail::_get_context(), (unsigned char*) c.data(), (unsigned char*) d.data() ) > 0 ); - - compact_signature result; - memcpy( result.begin() + 1, k.begin() + 1, 32 ); - memcpy( result.begin() + 33, c.data(), 32 ); - canonicalize( result.begin() + 33 ); + + // printf("unblinded: "); print(result.begin() + 33); printf("\n"); - for ( int i = 0; i < 4; i++ ) - { - unsigned char pubkey[33]; - int pklen = 33; - if ( secp256k1_ecdsa_recover_compact( detail::_get_context(), (unsigned char*) hash.data(), - (unsigned char*) result.begin() + 1, - pubkey, &pklen, 1, i ) ) - { - if ( !memcmp( t.begin(), pubkey, sizeof(pubkey) ) ) - { - *result.begin() = 27 + 4 + i; - return result; // } else { // printf("Candidate: "); print( pubkey ); printf("\n"); - } - } - } - FC_ASSERT( 0, "Failed to unblind - use different i" ); } commitment_type blind( const blind_factor_type& blind, uint64_t value ) diff --git a/libraries/fc/src/log/file_appender.cpp b/libraries/fc/src/log/file_appender.cpp index 85b69c61..5821f62a 100644 --- a/libraries/fc/src/log/file_appender.cpp +++ b/libraries/fc/src/log/file_appender.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace fc { From de2be1a2adf70b412a242677e640529c3c78ce72 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 15:44:40 +0800 Subject: [PATCH 02/38] fix bugs for compiling --- .../websocketpp/websocketpp/transport/asio/security/tls.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/fc/vendor/websocketpp/websocketpp/transport/asio/security/tls.hpp b/libraries/fc/vendor/websocketpp/websocketpp/transport/asio/security/tls.hpp index 7b32db81..a8aafec5 100644 --- a/libraries/fc/vendor/websocketpp/websocketpp/transport/asio/security/tls.hpp +++ b/libraries/fc/vendor/websocketpp/websocketpp/transport/asio/security/tls.hpp @@ -355,13 +355,9 @@ class connection : public lib::enable_shared_from_this { template lib::error_code translate_ec(ErrorCodeType ec) { if (ec.category() == lib::asio::error::get_ssl_category()) { - if (ERR_GET_REASON(ec.value()) == SSL_R_SHORT_READ) { - return make_error_code(transport::error::tls_short_read); - } else { // We know it is a TLS related error, but otherwise don't know // more. Pass through as TLS generic. return make_error_code(transport::error::tls_error); - } } else { // We don't know any more information about this error so pass // through From 07afd3ef890f41e8b259aea6d378afc3dc7b72ab Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 15:56:56 +0800 Subject: [PATCH 03/38] fix codes in order to pass the compile --- libraries/fc/include/fc/reflect/typename.hpp | 2 +- libraries/fc/include/fc/static_variant.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/fc/include/fc/reflect/typename.hpp b/libraries/fc/include/fc/reflect/typename.hpp index a92eaea8..3a96e9ae 100644 --- a/libraries/fc/include/fc/reflect/typename.hpp +++ b/libraries/fc/include/fc/reflect/typename.hpp @@ -16,7 +16,7 @@ namespace fc { class exception; namespace ip { class address; } - template struct get_typename {}; + template struct get_typename; template<> struct get_typename { static const char* name() { return "int32_t"; } }; template<> struct get_typename { static const char* name() { return "int64_t"; } }; template<> struct get_typename { static const char* name() { return "int16_t"; } }; diff --git a/libraries/fc/include/fc/static_variant.hpp b/libraries/fc/include/fc/static_variant.hpp index 9aab7903..d6206c2b 100644 --- a/libraries/fc/include/fc/static_variant.hpp +++ b/libraries/fc/include/fc/static_variant.hpp @@ -382,5 +382,5 @@ struct visitor { s.visit( to_static_variant(ar[1]) ); } - template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; + template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; } // namespace fc From 91fdcb7134d3a249744fc6d435db93c7f05486e5 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 16:12:40 +0800 Subject: [PATCH 04/38] fix bugs --- libraries/app/include/graphene/app/api.hpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 9ceded60..bf06acbb 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -290,13 +290,8 @@ namespace graphene { namespace app { public: crypto_api(); - fc::ecc::blind_signature blind_sign( const extended_private_key_type& key, const fc::ecc::blinded_hash& hash, int i ); + * @brief Generates a pedersen commitment: *commit = blind * G + value * G2. - signature_type unblind_signature( const extended_private_key_type& key, - const extended_public_key_type& bob, - const fc::ecc::blind_signature& sig, - const fc::sha256& hash, - int i ); fc::ecc::commitment_type blind( const fc::ecc::blind_factor_type& blind, uint64_t value ); @@ -490,8 +485,6 @@ FC_API(graphene::app::network_node_api, (set_advanced_node_parameters) ) FC_API(graphene::app::crypto_api, - (blind_sign) - (unblind_signature) (blind) (blind_sum) (verify_sum) From e603aaebaec61af32e9b7172ba6ba7e415fdcfc0 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 16:15:18 +0800 Subject: [PATCH 05/38] fix bugs --- libraries/app/include/graphene/app/api.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index bf06acbb..e09145eb 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -289,9 +289,14 @@ namespace graphene { namespace app { { public: crypto_api(); - + /** * @brief Generates a pedersen commitment: *commit = blind * G + value * G2. - + * The commitment is 33 bytes, the blinding factor is 32 bytes. + * For more information about pederson commitment check url https://en.wikipedia.org/wiki/Commitment_scheme + * @param blind Sha-256 blind factor type + * @param value Positive 64-bit integer value + * @return A 33-byte pedersen commitment: *commit = blind * G + value * G2 + */ fc::ecc::commitment_type blind( const fc::ecc::blind_factor_type& blind, uint64_t value ); From a8a0b3862d77ac85782d9f3ae11ff8cc27920147 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 16:36:17 +0800 Subject: [PATCH 06/38] fix bugs in order to compile in ubuntu18.04 --- libraries/app/api.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 08bb6c14..a8beca53 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -705,19 +705,7 @@ namespace graphene { namespace app { crypto_api::crypto_api(){}; - blind_signature crypto_api::blind_sign( const extended_private_key_type& key, const blinded_hash& hash, int i ) - { - return fc::ecc::extended_private_key( key ).blind_sign( hash, i ); - } - signature_type crypto_api::unblind_signature( const extended_private_key_type& key, - const extended_public_key_type& bob, - const blind_signature& sig, - const fc::sha256& hash, - int i ) - { - return fc::ecc::extended_private_key( key ).unblind_signature( extended_public_key( bob ), sig, hash, i ); - } commitment_type crypto_api::blind( const blind_factor_type& blind, uint64_t value ) { From 9c018cc7d8cb0f8e751f64c99d1722b311db455e Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 30 Jun 2020 18:22:21 +0800 Subject: [PATCH 07/38] fix make cxx flags in order to compile on ubuntu 18.04 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e9e59ff..04e131b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,7 +149,7 @@ else( WIN32 ) # Apple AND Linux else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BlockLinks on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall -pthread" ) set( rt_library rt ) set( pthread_library pthread) if ( NOT DEFINED crypto_library ) From 09b8041b837c78c8471875c2c58d68bd2ae0fb1e Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Thu, 9 Jul 2020 14:15:42 +0800 Subject: [PATCH 08/38] add for seed node --- libraries/app/api.cpp | 4 +- libraries/app/application.cpp | 47 ++++++++++++++++++- libraries/app/include/graphene/app/api.hpp | 3 +- .../app/include/graphene/app/application.hpp | 1 + .../crosschain/crosschain_interface_ltc.cpp | 10 +++- .../graphene/crosschain/crosschain_impl.hpp | 2 +- .../wallet/include/graphene/wallet/wallet.hpp | 4 +- libraries/wallet/wallet.cpp | 8 +++- programs/witness_node/main.cpp | 1 + 9 files changed, 71 insertions(+), 9 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index a8beca53..89e9c683 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -350,7 +350,9 @@ namespace graphene { namespace app { { return _app.p2p_node()->get_potential_peers(); } - + void network_node_api::update_seed_node() { + _app.add_seed_node(); + } fc::variant_object network_node_api::get_advanced_node_parameters() const { return _app.p2p_node()->get_advanced_node_parameters(); diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 224c3ce4..2f78c1c9 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -193,6 +193,7 @@ namespace detail { { // https://blocklinkstalk.org/index.php/topic,23715.0.html vector seeds = { + "117.78.44.37:9034", "47.74.2.123:9034", "47.74.23.176:9034", @@ -220,6 +221,7 @@ namespace detail { "seeds.blocklinks.eu:1776" // pc (http://seeds.quisquis.de/blocklinks.html) */ }; + for( const string& endpoint_string : seeds ) { try { @@ -249,7 +251,48 @@ namespace detail { std::vector()); } FC_CAPTURE_AND_RETHROW() } + void add_seed_node() { + try { + fc::http::connection_sync conn; + crosschain_interface_btc temp; + bool bgetconnect = temp.connect_midware(conn, true); + if (bgetconnect) + { + std::ostringstream req_body; + req_body << "{ \"jsonrpc\": \"2.0\", \ + \"id\" : \"45\", \ + \"method\" : \"Zchain.Query.GetSeedNode\" ,\ + \"params\" : {}}"; + //_rpc_url = _rpc_url + _config["ip"].as_string() + ":" + std::string(_config["port"].as_string()) + "/api"; + fc::http::headers _rpc_headers; + auto reply = conn.request("POST", "http://0.0.0.0:9999/api", req_body.str(), _rpc_headers); + //auto reply = conn.request("POST", string(eip), bodddy); + if (reply.status == fc::http::reply::OK) + { + auto resp = fc::json::from_string(std::string(reply.body.begin(), reply.body.end())).get_object(); + //std::cout << std::string(reply.body.begin(), reply.body.end()) << std::endl; + if (resp.contains("result")) { + auto ret = resp["result"].get_array(); + for (size_t i = 0; i < ret.size(); ++i) + { + std::vector endpoints = resolve_string_to_ip_endpoints(ret[i].as_string()); + for (const fc::ip::endpoint& endpoint : endpoints) + { + _p2p_network->add_node(endpoint); + } + } + } + } + } + + } + catch (const fc::exception& e) { + wlog("cant get seednode ${e} while adding seed node", + ("e", e.to_detail_string())); + } + + } std::vector resolve_string_to_ip_endpoints(const std::string& endpoint_string) { try @@ -1271,7 +1314,9 @@ void application::startup() throw; } } - +void application::add_seed_node() { + my->add_seed_node(); +} std::shared_ptr application::get_plugin(const string& name) const { return my->_plugins[name]; diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index e09145eb..1342b70d 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -280,7 +280,7 @@ namespace graphene { namespace app { * @brief Return list of potential peers */ std::vector get_potential_peers() const; - + void update_seed_node(); private: application& _app; }; @@ -488,6 +488,7 @@ FC_API(graphene::app::network_node_api, (get_potential_peers) (get_advanced_node_parameters) (set_advanced_node_parameters) + (update_seed_node) ) FC_API(graphene::app::crypto_api, (blind) diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 5c34cc93..7a50c996 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -51,6 +51,7 @@ namespace graphene { namespace app { void shutdown_plugins(); void stop_block_processing(); void start_block_processing(); + void add_seed_node(); template std::shared_ptr register_plugin() { diff --git a/libraries/crosschain/crosschain_interface_ltc.cpp b/libraries/crosschain/crosschain_interface_ltc.cpp index c93cc29f..16f78f21 100644 --- a/libraries/crosschain/crosschain_interface_ltc.cpp +++ b/libraries/crosschain/crosschain_interface_ltc.cpp @@ -825,11 +825,12 @@ namespace graphene { } return std::vector(); } - void abstract_crosschain_interface::connect_midware(fc::http::connection_sync& con) + bool abstract_crosschain_interface::connect_midware(fc::http::connection_sync& con, bool onetime) { vector counts; int ep_idx = -1; + bool get_from_mid = false; while(ep_idx==-1) { bool caught = false; @@ -849,10 +850,14 @@ namespace graphene { //调整顺序 if (ep_idx != 0) swap(midware_eps[0], midware_eps[ep_idx]); - return; + return true; } catch (...) { + if (onetime && get_from_mid) + { + return false; + } caught = true; } if (caught&&b_get_eps_from_service) { @@ -864,6 +869,7 @@ namespace graphene { set_midwares(servers); else set_midwares(midware_eps_backup); + get_from_mid = onetime; } catch (...) { diff --git a/libraries/crosschain/include/graphene/crosschain/crosschain_impl.hpp b/libraries/crosschain/include/graphene/crosschain/crosschain_impl.hpp index bf47f079..d464b6d9 100644 --- a/libraries/crosschain/include/graphene/crosschain/crosschain_impl.hpp +++ b/libraries/crosschain/include/graphene/crosschain/crosschain_impl.hpp @@ -147,7 +147,7 @@ namespace graphene { static std::vector midware_eps_backup; static bool b_get_eps_from_service; static std::map> connect_counts; - void connect_midware(fc::http::connection_sync& con); + bool connect_midware(fc::http::connection_sync& con,bool onetime = false); static void set_midwares(const std::vector& midware_eps); static void set_midwares_backup(const std::vector& midware_eps); static std::vector get_midware_eps(); diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 31849e7f..aa81f698 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2141,6 +2141,7 @@ class wallet_api void set_gas_limit_in_block(const share_type& new_limit); contract_storage_view get_contract_storage(const address& contract_address, const string& storage_name); vector get_votes(const string& account) const; + void update_seed_node(); /*void testaaa1() {} void testaaa2() {} void testaaa3() {} @@ -3211,7 +3212,7 @@ FC_API( graphene::wallet::wallet_api, (list_senator_members) (list_all_senators) (create_citizen) - (set_desired_citizen_and_senator_member_count) + //(set_desired_citizen_and_senator_member_count) (get_account) (change_account_name) (remove_local_account) @@ -3400,4 +3401,5 @@ FC_API( graphene::wallet::wallet_api, (confirm_undertaker) (get_pledge) (build_transaction) + (update_seed_node) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4dca8815..26098065 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1597,7 +1597,9 @@ class wallet_api_impl return _remote_db->get_pledge(); }FC_LOG_AND_RETHROW(); } - + void update_seed_node() { + (*_remote_net_node)->update_seed_node(); + } full_transaction register_account(string name, bool broadcast) { try { @@ -8407,7 +8409,9 @@ fc::uint128_t wallet_api::get_pledge() const { return my->get_pledge(); } - +void wallet_api::update_seed_node() { + my->update_seed_node(); +} fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const { return detail::derive_private_key( prefix_string, sequence_number ); diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 1cdfcb27..547858aa 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -232,6 +232,7 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); + node->add_seed_node(); auto chain_types = node->get_crosschain_chain_types(); for (auto& chain_type : chain_types) { From 9fe830df090357bc6009f08acd8103e676c1bec8 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Tue, 14 Jul 2020 09:51:26 +0800 Subject: [PATCH 09/38] add seed node --- libraries/app/application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 2f78c1c9..1c1313e6 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -200,7 +200,8 @@ namespace detail { "47.74.37.107:9034", "52.194.253.245:9034", "36.152.8.188:9034", - "172.81.250.51:9034" + "172.81.250.51:9034", + "106.13.38.27:9034" /* "104.236.144.84:1777", // puppies (USA) "128.199.143.47:2015", // Harvey (Singapore) From dfce88a0aedb06e5a8d1d3e9852831927b745ac3 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 14 Jul 2020 10:27:03 +0800 Subject: [PATCH 10/38] modify version --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 26098065..d486dd51 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -685,7 +685,7 @@ class wallet_api_impl result["head_block_age"] = fc::get_approximate_relative_time_string(dynamic_props.time, time_point_sec(time_point::now()), " old"); - result["version"] = "1.3.1"; + result["version"] = "1.3.2"; result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; //result["data_dir"] = (*_remote_local_node)->get_data_dir(); From 3ef4d11660f0706f5c527fbbce440b51ed172ed8 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Wed, 15 Jul 2020 11:35:42 +0800 Subject: [PATCH 11/38] fix bug --- libraries/wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index aa81f698..ad4b1057 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2141,7 +2141,7 @@ class wallet_api void set_gas_limit_in_block(const share_type& new_limit); contract_storage_view get_contract_storage(const address& contract_address, const string& storage_name); vector get_votes(const string& account) const; - void update_seed_node(); + bool update_seed_node(); /*void testaaa1() {} void testaaa2() {} void testaaa3() {} diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index d486dd51..d5184c7e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1597,8 +1597,10 @@ class wallet_api_impl return _remote_db->get_pledge(); }FC_LOG_AND_RETHROW(); } - void update_seed_node() { + bool update_seed_node() { + use_network_node_api(); (*_remote_net_node)->update_seed_node(); + return true; } full_transaction register_account(string name, bool broadcast) { @@ -8409,8 +8411,8 @@ fc::uint128_t wallet_api::get_pledge() const { return my->get_pledge(); } -void wallet_api::update_seed_node() { - my->update_seed_node(); +bool wallet_api::update_seed_node() { + return my->update_seed_node(); } fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const { From 73b9799c826cc2db48e52f8641da7d7e4c762f8a Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Wed, 15 Jul 2020 12:17:27 +0800 Subject: [PATCH 12/38] change smart_ref to shared_ptr --- CMakeLists.txt | 2 +- libraries/app/application.cpp | 2 +- libraries/app/database_api.cpp | 16 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/db_getter.cpp | 2 +- libraries/chain/db_init.cpp | 2 +- libraries/chain/db_maint.cpp | 2 +- .../chain/protocol/chain_parameters.hpp | 4 +- .../graphene/chain/protocol/fee_schedule.hpp | 3 + .../include/graphene/chain/protocol/types.hpp | 14 + libraries/chain/protocol/types.cpp | 8 + libraries/plugins/witness/witness.cpp | 8 +- libraries/uvm | 2 +- libraries/wallet/CMakeLists.txt | 13 - libraries/wallet/wallet.cpp | 254 +++++++++--------- tests/common/database_fixture.cpp | 8 +- 16 files changed, 178 insertions(+), 164 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e131b4..5054e541 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,7 @@ endif() add_subdirectory( libraries ) add_subdirectory( programs ) -add_subdirectory( tests ) +#add_subdirectory( tests ) if (ENABLE_INSTALLER) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 2f78c1c9..20f179a1 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -84,7 +84,7 @@ namespace detail { auto hyper_exchange_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("hyper-exchange"))); dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(hyper_exchange_key))); genesis_state_type initial_state; - initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION); + initial_state.initial_parameters.get_mutable_fees() = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION); initial_state.initial_active_miners = GRAPHENE_DEFAULT_MIN_MINER_COUNT; initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() / initial_state.initial_parameters.block_interval * diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f5a6a09b..10bb6b0f 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2949,9 +2949,9 @@ std::pair database_api::register_contract_testing(const strin signed_transaction tx; tx.operations.push_back(contract_register_op); - auto current_fees = get_global_properties().parameters.current_fees; + const auto current_fees = get_global_properties().parameters.get_current_fees(); for (auto& op : tx.operations) - current_fees->set_fee(op); + current_fees.set_fee(op); signed_transaction signed_tx(tx); auto dyn_props = get_dynamic_global_properties(); signed_tx.set_reference_block(dyn_props.head_block_id); @@ -2998,9 +2998,9 @@ std::pair database_api::transfer_to_contract_testing(string p signed_transaction tx; tx.operations.push_back(transfer_to_contract_op); - auto current_fees = get_global_properties().parameters.current_fees; + const auto current_fees = get_global_properties().parameters.get_current_fees(); for (auto& op : tx.operations) - current_fees->set_fee(op); + current_fees.set_fee(op); auto dyn_props = get_dynamic_global_properties(); @@ -3065,9 +3065,9 @@ execution_result database_api::invoke_contract_testing(const string & pubkey, co signed_transaction tx; tx.operations.push_back(contract_invoke_op); - auto current_fees = get_global_properties().parameters.current_fees; + auto current_fees = get_global_properties().parameters.get_current_fees(); for (auto& op : tx.operations) - current_fees->set_fee(op); + current_fees.set_fee(op); auto dyn_props = get_dynamic_global_properties(); tx.set_reference_block(dyn_props.head_block_id); @@ -3157,9 +3157,9 @@ string database_api::invoke_contract_offline(const string & caller_pubkey_str, c //contract_invoke_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(contract_invoke_op); - auto current_fees = get_global_properties().parameters.current_fees; + auto current_fees = get_global_properties().parameters.get_current_fees(); for (auto& op : tx.operations) - current_fees->set_fee(op); + current_fees.set_fee(op); auto dyn_props = get_dynamic_global_properties(); tx.set_reference_block(dyn_props.head_block_id); diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index a16d431f..72a983e0 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -169,7 +169,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0 ) db().modify(global_properties, [&dynamic_properties](global_property_object& p) { - p.parameters.current_fees->get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; + p.parameters.get_mutable_fees().get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; }); if( o.extensions.value.owner_special_authority.valid() diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index be8bc2d5..35b59dce 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -64,7 +64,7 @@ const lockbalance_record_object& database::get_lockbalance_records() const const fee_schedule& database::current_fee_schedule()const { - return get_global_properties().parameters.current_fees; + return get_global_properties().parameters.get_current_fees(); } time_point_sec database::head_block_time()const diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 5266e3ab..fd99d607 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -492,7 +492,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.parameters = genesis_state.initial_parameters; // Set fees to zero initially, so that genesis initialization needs not pay them // We'll fix it at the end of the function - p.parameters.current_fees->zero_all_fees(); + p.parameters.get_mutable_fees().zero_all_fees(); p.unorder_blocks_match[6307200] = 27 * GRAPHENE_HXCHAIN_PRECISION; p.unorder_blocks_match[12614400] = 25 * GRAPHENE_HXCHAIN_PRECISION; p.unorder_blocks_match[18921600] = 24 * GRAPHENE_HXCHAIN_PRECISION; diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 75270b4e..693002b9 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -1081,7 +1081,7 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g modify(gpo, [this](global_property_object& p) { // Remove scaling of account registration fee const auto& dgpo = get_dynamic_global_properties(); - p.parameters.current_fees->get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * + p.parameters.get_mutable_fees().get().basic_fee >>= p.parameters.account_fee_scale_bitshifts * (dgpo.accounts_registered_this_interval / p.parameters.accounts_per_fee_scale); if( p.pending_parameters ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index a7621178..0c5691b7 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -40,7 +40,9 @@ namespace graphene { namespace chain { struct chain_parameters { /** using a smart ref breaks the circular dependency created between operations and the fee schedule */ - smart_ref current_fees; ///< current schedule of fees + std::shared_ptr current_fees; ///< current schedule of fees + const fee_schedule& get_current_fees() const { FC_ASSERT(current_fees); return *current_fees; } + fee_schedule& get_mutable_fees() { FC_ASSERT(current_fees); return const_cast(*current_fees); } uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events uint8_t maintenance_skip_slots = GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS; ///< number of block_intervals to skip at maintenance time diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index e250ab17..481a48f9 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -77,6 +77,9 @@ namespace graphene { namespace chain { */ flat_set parameters; uint32_t scale = GRAPHENE_100_PERCENT; ///< fee * scale / GRAPHENE_100_PERCENT + friend bool operator ==(const fee_schedule& a, const fee_schedule& b) { + return a.parameters == b.parameters&&a.scale == b.scale; + } }; typedef fee_schedule fee_schedule_type; diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 5cf5c781..cec58b61 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -413,6 +413,7 @@ namespace graphene { namespace chain { friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); }; + struct fee_schedule; } } // graphene::chain namespace fc @@ -423,6 +424,19 @@ namespace fc void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo ); void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo ); void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo ); + void from_variant(const fc::variant& var, std::shared_ptr& vo); + template<> + struct get_typename> { + static const char* name() { + return "shared_ptr"; + } + }; + template<> + struct get_typename> { + static const char* name() { + return "shared_ptr"; + } + }; } FC_REFLECT( graphene::chain::public_key_type, (key_data) ) diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp index 08091d59..90f17043 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/chain/protocol/types.cpp @@ -23,6 +23,7 @@ */ #include #include +#include #include #include @@ -244,6 +245,13 @@ namespace fc { vo = graphene::chain::extended_public_key_type( var.as_string() ); } + void from_variant(const fc::variant& var, std::shared_ptr& vo) { + // If it's null, just make a new one + if (!vo) vo = std::make_shared(); + // Convert the non-const shared_ptr to a non-const fee_schedule& so we can write it + // Don't decrement max_depth since we're not actually deserializing at this step + from_variant(var, const_cast(*vo)); + } void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo ) { diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index 4e053dbb..c286114a 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -323,7 +323,7 @@ void miner_plugin::check_eths_generate_multi_addr(miner_id_type miner, fc::ecc:: op.chain_type = multi_withsign_trx->symbol; signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, db.get_global_properties().parameters.current_fees); + set_operation_fees(trx, db.get_global_properties().parameters.get_current_fees()); trx.set_reference_block(dyn_props.head_block_id); trx.set_expiration(dyn_props.time + fc::seconds(30 + expiration_time_offset)); trx.sign(pk, db.get_chain_id()); @@ -457,7 +457,7 @@ fc::variant miner_plugin::check_generate_multi_addr(miner_id_type miner,fc::ecc: op.guard_to_sign = sign_guard_id; op.chain_type = iter.symbol; trx.operations.emplace_back(op); - set_operation_fees(trx, db.get_global_properties().parameters.current_fees); + set_operation_fees(trx, db.get_global_properties().parameters.get_current_fees()); trx.set_reference_block(dyn_props.head_block_id); trx.set_expiration(dyn_props.time + fc::seconds(30 + expiration_time_offset)); trx.sign(pk, db.get_chain_id()); @@ -480,7 +480,7 @@ fc::variant miner_plugin::check_generate_multi_addr(miner_id_type miner,fc::ecc: op.multi_redeemScript_hot = multi_addr_hot_obj["redeemScript"]; op.chain_type = iter.symbol; trx.operations.emplace_back(op); - set_operation_fees(trx,db.get_global_properties().parameters.current_fees); + set_operation_fees(trx,db.get_global_properties().parameters.get_current_fees()); trx.set_reference_block(dyn_props.head_block_id); trx.set_expiration(dyn_props.time + fc::seconds(30 + expiration_time_offset)); trx.sign(pk, db.get_chain_id()); @@ -516,7 +516,7 @@ void miner_plugin::check_multi_transfer(miner_id_type miner, fc::ecc::private_ke op.id = transfer.id; signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, db.get_global_properties().parameters.current_fees); + set_operation_fees(trx, db.get_global_properties().parameters.get_current_fees()); trx.set_reference_block(dyn_props.head_block_id); trx.set_expiration(dyn_props.time + fc::seconds(30 + expiration_time_offset)); trx.sign(pk, db.get_chain_id()); diff --git a/libraries/uvm b/libraries/uvm index bff8ac7f..99dedb58 160000 --- a/libraries/uvm +++ b/libraries/uvm @@ -1 +1 @@ -Subproject commit bff8ac7fbbe1750cb4bac2a384a004cadefd3653 +Subproject commit 99dedb58aedf77fe243b14a79d0032a16e2f42aa diff --git a/libraries/wallet/CMakeLists.txt b/libraries/wallet/CMakeLists.txt index 52ef8726..7a4d59c6 100644 --- a/libraries/wallet/CMakeLists.txt +++ b/libraries/wallet/CMakeLists.txt @@ -3,24 +3,11 @@ file(GLOB HEADERS "include/graphene/wallet/*.hpp") find_package( Perl ) find_package( Doxygen ) -if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" ) - configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ) - add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${DOXYGEN_EXECUTABLE} - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile include/graphene/wallet/wallet.hpp ) - add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp - COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm ) -else() # no perl and doxygen, generate the best docs we can at runtime from reflection add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/api_documentation_standin.cpp ) -endif() add_library( graphene_wallet wallet.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../chain/contract_entry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../chain/protocol/memo.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} ) target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain uvm graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 26098065..bbe1ac4d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1359,7 +1359,7 @@ class wallet_api_impl temp["op"] = op; auto b_op = fc::variant(temp).as(); tx.operations.push_back(b_op.op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); tx.set_reference_block(dyn_props.head_block_id); @@ -1437,7 +1437,7 @@ class wallet_api_impl if( review_period_seconds ) op.review_period_seconds = review_period_seconds; trx.operations = {op}; - _remote_db->get_global_properties().parameters.current_fees->set_fee( trx.operations.front() ); + _remote_db->get_global_properties().parameters.get_current_fees().set_fee( trx.operations.front() ); return trx = sign_transaction(trx, broadcast); } @@ -1455,7 +1455,7 @@ class wallet_api_impl op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -1476,7 +1476,7 @@ class wallet_api_impl op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((proposer)(title)(options)(expiration)(broadcast)) @@ -1525,7 +1525,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(trx_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); } FC_CAPTURE_AND_RETHROW((pay_back_owner)(nums)(broadcast)) @@ -1546,7 +1546,7 @@ class wallet_api_impl op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx,_remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx,_remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx,broadcast); @@ -1623,7 +1623,7 @@ class wallet_api_impl account_create_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(account_create_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1677,7 +1677,7 @@ class wallet_api_impl contract_register_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(contract_register_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1723,7 +1723,7 @@ class wallet_api_impl contract_register_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(contract_register_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1772,7 +1772,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(contract_register_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1828,7 +1828,7 @@ class wallet_api_impl n_contract_register_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(n_contract_register_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1870,7 +1870,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(n_contract_register_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -1957,7 +1957,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(contract_invoke_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2043,7 +2043,7 @@ class wallet_api_impl contract_invoke_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(contract_invoke_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2127,7 +2127,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(contract_invoke_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2182,7 +2182,7 @@ class wallet_api_impl contract_upgrade_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(contract_upgrade_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2433,7 +2433,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(contract_upgrade_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2496,7 +2496,7 @@ class wallet_api_impl transfer_to_contract_op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(transfer_to_contract_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2535,7 +2535,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(transfer_to_contract_op); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); @@ -2582,7 +2582,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -2628,7 +2628,7 @@ class wallet_api_impl tx.operations.push_back( account_create_op ); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + const auto current_fees = _remote_db->get_global_properties().parameters.get_current_fees(); set_operation_fees( tx, current_fees ); vector paying_keys = registrar_account_object.active.get_keys(); @@ -2668,7 +2668,7 @@ class wallet_api_impl op.account_to_upgrade = account_obj.get_id(); op.upgrade_to_lifetime_member = true; tx.operations = {op}; - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2691,7 +2691,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.push_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(asset_orign)(asset_target)(symbol)(broadcast)) @@ -2708,7 +2708,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.push_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -2795,7 +2795,7 @@ class wallet_api_impl tx.operations.push_back( account_create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); vector paying_keys = registrar_account_object.active.get_keys(); @@ -2946,7 +2946,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( create_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -2974,7 +2974,7 @@ class wallet_api_impl op.core_fee_paid = core_fee_paid; signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3013,7 +3013,7 @@ class wallet_api_impl op.erc_address = erc_real_address; signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3037,7 +3037,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3058,7 +3058,7 @@ class wallet_api_impl full_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3082,7 +3082,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3104,7 +3104,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( publish_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3129,7 +3129,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(publish_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3154,7 +3154,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( fund_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3176,7 +3176,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( reserve_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3197,7 +3197,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( settle_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3218,7 +3218,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( settle_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3236,7 +3236,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( whitelist_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3270,7 +3270,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(guard_member_create_op); - set_operation_fees( tx, get_global_properties().parameters.current_fees); + set_operation_fees( tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3298,7 +3298,7 @@ class wallet_api_impl prop_op.proposed_ops.emplace_back(guard_create_op); //prop_op.review_period_seconds = 100; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3326,7 +3326,7 @@ class wallet_api_impl //prop_op.type = vote_id_type::committee; //prop_op.review_period_seconds = 0; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3370,7 +3370,7 @@ class wallet_api_impl op.new_options = acct.options; signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); full_transaction res= sign_transaction(tx, broadcast); @@ -3433,7 +3433,7 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(account).addr; prop_op.proposed_ops.emplace_back(publisher_appointed_op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(publisher)(symbol)(expiration_time)(broadcast)) @@ -3459,7 +3459,7 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(account).addr; prop_op.proposed_ops.emplace_back(publisher_appointed_op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(publisher)(symbol)(expiration_time)(broadcast)) @@ -3486,7 +3486,7 @@ class wallet_api_impl prop_op.proposed_ops.emplace_back(publisher_appointed_op); //prop_op.type = vote_id_type::witness; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(gas_price)(symbol)(expiration_time)(broadcast)) @@ -3512,7 +3512,7 @@ class wallet_api_impl prop_op.proposed_ops.emplace_back(publisher_appointed_op); //prop_op.type = vote_id_type::witness; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(fee)(symbol)(expiration_time)(broadcast)) @@ -3538,7 +3538,7 @@ class wallet_api_impl prop_op.proposed_ops.emplace_back(publisher_appointed_op); //prop_op.type = vote_id_type::witness; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(lockbalance)(expiration_time)(broadcast)) @@ -3561,7 +3561,7 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(account).addr; prop_op.proposed_ops.emplace_back(determine_op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(blocks_pays)(expiration_time)(broadcast)) @@ -3584,7 +3584,7 @@ class wallet_api_impl prop_op.type = vote_id_type::senator; current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(block_addr)(expiration_time)(broadcast)) @@ -3612,7 +3612,7 @@ class wallet_api_impl prop_op.type = vote_id_type::senator; current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3630,7 +3630,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3649,7 +3649,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(addr)(balance)(broadcast)) @@ -3682,7 +3682,7 @@ class wallet_api_impl prop_op.type = vote_id_type::senator; current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -3707,7 +3707,7 @@ class wallet_api_impl prop_op.type = vote_id_type::senator; current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(block_addr)(expiration_time)(broadcast)) @@ -3733,7 +3733,7 @@ class wallet_api_impl prop_op.proposed_ops.emplace_back(publisher_appointed_op); //prop_op.type = vote_id_type::witness; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(can)(expiration_time)(broadcast)) @@ -3768,7 +3768,7 @@ class wallet_api_impl op.guarantee_id = get_guarantee_id(); signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); sign_transaction(tx,broadcast); result[pubkey] = op.multisignature; @@ -3890,7 +3890,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(miner_create_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); _wallet.pending_miner_registrations[owner_account] = key_to_wif(active_private_key); @@ -3917,7 +3917,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( witness_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -3968,7 +3968,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -4033,7 +4033,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -4091,7 +4091,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( vesting_balance_withdraw_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -4118,7 +4118,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); }FC_CAPTURE_AND_RETHROW((proposer)(trxid)(exception_time)(broadcast)) @@ -4137,7 +4137,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.push_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx,broadcast); @@ -4169,7 +4169,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4200,7 +4200,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4229,7 +4229,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4258,7 +4258,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4288,7 +4288,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4317,7 +4317,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4345,7 +4345,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4375,7 +4375,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); } @@ -4404,7 +4404,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); } @@ -4432,7 +4432,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4544,7 +4544,7 @@ class wallet_api_impl op.signature = key->sign_compact(fc::sha256::hash(op.new_address_hot + op.new_address_cold)); signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, get_global_properties().parameters.current_fees); + set_operation_fees(trx, get_global_properties().parameters.get_current_fees()); trx.validate(); auto res = sign_transaction(trx, broadcast); return res; @@ -4571,7 +4571,7 @@ class wallet_api_impl op.signature = key->sign_compact(fc::sha256::hash(op.new_address_hot + op.new_address_cold)); signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, get_global_properties().parameters.current_fees); + set_operation_fees(trx, get_global_properties().parameters.get_current_fees()); trx.validate(); auto res = sign_transaction(trx, broadcast); return res; @@ -4653,7 +4653,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, get_global_properties().parameters.current_fees); + set_operation_fees(trx, get_global_properties().parameters.get_current_fees()); trx.validate(); auto res= sign_transaction(trx,broadcast); boost::filesystem::remove(tmpf); @@ -4705,7 +4705,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4756,7 +4756,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, get_global_properties().parameters.current_fees); + set_operation_fees(trx, get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx,broadcast); }FC_CAPTURE_AND_RETHROW((account)(id)(broadcast)) @@ -4789,7 +4789,7 @@ class wallet_api_impl signed_transaction trx; trx.operations.emplace_back(prop_op); - set_operation_fees(trx, current_params.current_fees); + set_operation_fees(trx, current_params.get_current_fees()); trx.validate(); return sign_transaction(trx,broadcast); @@ -4848,7 +4848,7 @@ class wallet_api_impl op.tunnel_signature = script; //signature of tunnel address. signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); }FC_CAPTURE_AND_RETHROW((link_account)(tunnel_account)(script)(symbol)(broadcast)) @@ -4906,7 +4906,7 @@ class wallet_api_impl crosschain->create_signature(prk_ptr, transfer_tunnel_account, op.tunnel_signature); signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4941,7 +4941,7 @@ class wallet_api_impl op.tunnel_signature = script; signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -4989,7 +4989,7 @@ class wallet_api_impl crosschain->create_signature(prk_ptr, tunnel_account, op.tunnel_signature); signed_transaction trx; trx.operations.emplace_back(op); - set_operation_fees(trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); }FC_CAPTURE_AND_RETHROW((link_account)(tunnel_account)(symbol)(broadcast)) @@ -5032,7 +5032,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -5066,7 +5066,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -5097,7 +5097,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -5123,7 +5123,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back( account_update_op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -5299,7 +5299,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction( tx, broadcast ); @@ -5320,7 +5320,7 @@ class wallet_api_impl signed_transaction trx; trx.operations = {op}; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); idump((broadcast)); @@ -5517,7 +5517,7 @@ class wallet_api_impl signed_transaction transaction; transaction.operations.push_back(tx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -5668,7 +5668,7 @@ class wallet_api_impl tx_op.coldhot_transfer_sign = siging; signed_transaction transaction; transaction.operations.push_back(tx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -5785,7 +5785,7 @@ class wallet_api_impl tx_op.coldhot_transfer_sign = siging; signed_transaction transaction; transaction.operations.push_back(tx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); @@ -5851,7 +5851,7 @@ class wallet_api_impl trx_op.guard_address = account_obj.addr; signed_transaction transaction; transaction.operations.push_back(trx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); @@ -5950,7 +5950,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction transaction; transaction.operations.push_back(prop_op); - set_operation_fees(transaction, current_params.current_fees); + set_operation_fees(transaction, current_params.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -5995,7 +5995,7 @@ class wallet_api_impl current_params.current_fees->set_fee(prop_op.proposed_ops.back().op); signed_transaction transaction; transaction.operations.push_back(prop_op); - set_operation_fees(transaction, current_params.current_fees); + set_operation_fees(transaction, current_params.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -6038,7 +6038,7 @@ class wallet_api_impl trx_op.guard_address = account_obj.addr; signed_transaction transaction; transaction.operations.push_back(trx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -6075,7 +6075,7 @@ class wallet_api_impl trx_op.guard_address = account_obj.addr; signed_transaction transaction; transaction.operations.push_back(trx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); // } @@ -6134,7 +6134,7 @@ class wallet_api_impl trx_op.guard_address = account_obj.addr; signed_transaction transaction; transaction.operations.push_back(trx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); } @@ -6178,7 +6178,7 @@ class wallet_api_impl trx_op.guard_address = account_obj.addr; signed_transaction transaction; transaction.operations.push_back(trx_op); - set_operation_fees(transaction, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(transaction, _remote_db->get_global_properties().parameters.get_current_fees()); transaction.validate(); sign_transaction(transaction, true); @@ -6218,7 +6218,7 @@ class wallet_api_impl op.fee_paying_account = get_object(order_id).seller; op.order = order_id; trx.operations = {op}; - set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.get_current_fees()); trx.validate(); return sign_transaction(trx, broadcast); @@ -6260,7 +6260,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6298,7 +6298,7 @@ class wallet_api_impl op.crosschain_account = multi_to_account; signed_transaction tx; tx.operations.push_back(op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((multi_account)(amount)(asset_symbol)(multi_to_account)(memo)) @@ -6333,7 +6333,7 @@ class wallet_api_impl } FC_ASSERT(tx.operations.size() <= 100, "should less than 100 operations."); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((lock_account)(lockbalances)(broadcast)) @@ -6361,7 +6361,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(lb_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6389,7 +6389,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(guard_lb_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6424,7 +6424,7 @@ class wallet_api_impl } FC_ASSERT(tx.operations.size() <= 100, "should less than 100 operations."); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((foreclose_account)(foreclose_balances)(broadcast)) @@ -6453,7 +6453,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(fcb_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6481,7 +6481,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(guard_fcb_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6524,7 +6524,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(u_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); tx.set_reference_block(dyn_props.head_block_id); @@ -6557,7 +6557,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(u_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); tx.set_reference_block(dyn_props.head_block_id); @@ -6590,7 +6590,7 @@ class wallet_api_impl } signed_transaction tx; tx.operations.push_back(xfer_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); @@ -6657,7 +6657,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(xfer_op); - set_operation_fees(tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6724,7 +6724,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(xfer_op); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -6754,7 +6754,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(issue_op); - set_operation_fees(tx,_remote_db->get_global_properties().parameters.current_fees); + set_operation_fees(tx,_remote_db->get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7000,7 +7000,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7034,7 +7034,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7067,7 +7067,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7108,7 +7108,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7122,7 +7122,7 @@ class wallet_api_impl bool broadcast = false) { const chain_parameters& current_params = get_global_properties().parameters; - const fee_schedule_type& current_fees = *(current_params.current_fees); + const fee_schedule_type& current_fees = (current_params.get_current_fees()); flat_map< int, fee_parameters > fee_map; fee_map.reserve( current_fees.parameters.size() ); @@ -7175,7 +7175,7 @@ class wallet_api_impl new_fees.scale = scale; chain_parameters new_params = current_params; - new_params.current_fees = new_fees; + new_params.get_mutable_fees() = new_fees; committee_member_update_global_parameters_operation update_op; update_op.new_parameters = new_params; @@ -7190,7 +7190,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); @@ -7224,7 +7224,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(update_op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); } @@ -7247,7 +7247,7 @@ class wallet_api_impl signed_transaction tx; tx.operations.push_back(update_op); - set_operation_fees(tx, get_global_properties().parameters.current_fees); + set_operation_fees(tx, get_global_properties().parameters.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); } @@ -10793,7 +10793,7 @@ vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id, tx.operations.reserve( ctx.ops.size() ); for( const balance_claim_operation& op : ctx.ops ) tx.operations.emplace_back( op ); - set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.get_current_fees() ); tx.validate(); signed_transaction signed_tx = sign_transaction( tx, false ); for( const address& addr : ctx.addrs ) @@ -11109,7 +11109,7 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke transfer_from_blind_operation from_blind; - auto fees = my->_remote_db->get_global_properties().parameters.current_fees; + auto fees = my->_remote_db->get_global_properties().parameters.get_current_fees(); fc::optional asset_obj = get_asset(symbol); FC_ASSERT(asset_obj.valid(), "Could not find asset matching ${asset}", ("asset", symbol)); auto amount = asset_obj->amount_from_string(amount_in); @@ -11188,7 +11188,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, blind_transfer_operation blind_tr; blind_tr.outputs.resize(2); - auto fees = my->_remote_db->get_global_properties().parameters.current_fees; + auto fees = my->_remote_db->get_global_properties().parameters.get_current_fees(); auto amount = asset_obj->amount_from_string(amount_in); @@ -11411,7 +11411,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name [&]( const blind_output& a, const blind_output& b ){ return a.commitment < b.commitment; } ); confirm.trx.operations.push_back( bop ); - my->set_operation_fees( confirm.trx, my->_remote_db->get_global_properties().parameters.current_fees); + my->set_operation_fees( confirm.trx, my->_remote_db->get_global_properties().parameters.get_current_fees()); confirm.trx.validate(); confirm.trx = sign_transaction(confirm.trx, broadcast); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 9f9a652f..175a2c1d 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -584,7 +584,7 @@ void database_fixture::change_fees( ) { const chain_parameters& current_chain_params = db.get_global_properties().parameters; - const fee_schedule& current_fees = *(current_chain_params.current_fees); + const fee_schedule& current_fees = (current_chain_params.get_mutable_fees()); flat_map< int, fee_parameters > fee_map; fee_map.reserve( current_fees.parameters.size() ); @@ -601,7 +601,7 @@ void database_fixture::change_fees( new_fees.scale = new_scale; chain_parameters new_chain_params = current_chain_params; - new_chain_params.current_fees = new_fees; + new_chain_params.get_mutable_fees() = new_fees; db.modify(db.get_global_properties(), [&](global_property_object& p) { p.parameters = new_chain_params; @@ -934,7 +934,7 @@ void database_fixture::enable_fees() { db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.current_fees = fee_schedule::get_default(); + gpo.parameters.get_mutable_fees() = fee_schedule::get_default(); }); } @@ -950,7 +950,7 @@ void database_fixture::upgrade_to_lifetime_member( const account_object& account account_upgrade_operation op; op.account_to_upgrade = account.get_id(); op.upgrade_to_lifetime_member = true; - op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); + op.fee = db.get_global_properties().parameters.get_current_fees().calculate_fee(op); trx.operations = {op}; db.push_transaction(trx, ~0); FC_ASSERT( op.account_to_upgrade(db).is_lifetime_member() ); From 638dd595225bc92bc5cd825b1672eb81be14eda4 Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Wed, 15 Jul 2020 15:36:28 +0800 Subject: [PATCH 13/38] remove smart_ref --- libraries/app/api.cpp | 2 +- libraries/app/application.cpp | 2 +- libraries/app/database_api.cpp | 2 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/block_database.cpp | 2 +- libraries/chain/coldhot_transfer_evaluate.cpp | 2 +- libraries/chain/committee_member_evaluator.cpp | 2 +- libraries/chain/confidential_evaluator.cpp | 2 +- libraries/chain/crosschain_record_evaluate.cpp | 2 +- libraries/chain/database.cpp | 2 +- libraries/chain/database_impl.cpp | 2 +- libraries/chain/fork_database.cpp | 2 +- libraries/chain/genesis_state.cpp | 2 +- libraries/chain/guard_refund_balance_evaluator.cpp | 2 +- .../include/graphene/chain/protocol/chain_parameters.hpp | 2 +- libraries/chain/include/graphene/chain/protocol/types.hpp | 3 +-- libraries/chain/market_evaluator.cpp | 2 +- libraries/chain/proposal_evaluator.cpp | 2 +- libraries/chain/protocol/fee_schedule.cpp | 5 +---- libraries/chain/protocol/proposal.cpp | 2 +- libraries/chain/protocol/referendum.cpp | 2 +- libraries/chain/protocol/transaction.cpp | 2 +- libraries/chain/referendum_evaluator.cpp | 2 +- libraries/crosschain/crosschain_interface_emu.cpp | 2 +- .../crosschain/crosschain_transaction_record_plugin.cpp | 2 +- libraries/db/undo_database.cpp | 2 +- libraries/egenesis/embed_genesis.cpp | 2 +- libraries/net/node.cpp | 2 +- libraries/plugins/account_history/account_history_plugin.cpp | 2 +- libraries/plugins/debug_witness/debug_api.cpp | 2 +- libraries/plugins/debug_witness/debug_witness.cpp | 2 +- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- libraries/plugins/market_history/market_history_plugin.cpp | 2 +- libraries/plugins/transaction/transaction_plugin.cpp | 2 +- libraries/plugins/witness/witness.cpp | 2 +- libraries/wallet/wallet.cpp | 2 +- programs/build_helpers/member_enumerator.cpp | 2 +- programs/cli_wallet/main.cpp | 2 +- programs/genesis_util/genesis_update.cpp | 2 +- programs/js_operation_serializer/main.cpp | 2 +- programs/size_checker/main.cpp | 2 +- 41 files changed, 41 insertions(+), 45 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 89e9c683..5883a411 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -38,7 +38,7 @@ #include #include #include -#include + #include #include #include diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index b1311a32..22fc8bba 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -37,7 +37,7 @@ #include #include -#include + #include #include diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 10bb6b0f..f250561c 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -26,7 +26,7 @@ #include #include -#include + #include diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 72a983e0..d4177704 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include + #include #include diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 245db56a..fb2bb6d9 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -24,7 +24,7 @@ #include #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/coldhot_transfer_evaluate.cpp b/libraries/chain/coldhot_transfer_evaluate.cpp index 46bf6d0d..0b4cb9c4 100644 --- a/libraries/chain/coldhot_transfer_evaluate.cpp +++ b/libraries/chain/coldhot_transfer_evaluate.cpp @@ -2,7 +2,7 @@ #include #include #include -#include + namespace graphene { namespace chain { void_result coldhot_transfer_evaluate::do_evaluate(const coldhot_transfer_operation& o) { diff --git a/libraries/chain/committee_member_evaluator.cpp b/libraries/chain/committee_member_evaluator.cpp index 24a04d83..b35e456f 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -35,7 +35,7 @@ #include #include -#include + #define GUARD_VOTES_EXPIRATION_TIME 7*24*3600 #define MINER_VOTES_REVIWE_TIME 24 * 3600 diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 11d70c20..68d61243 100644 --- a/libraries/chain/confidential_evaluator.cpp +++ b/libraries/chain/confidential_evaluator.cpp @@ -28,7 +28,7 @@ #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/crosschain_record_evaluate.cpp b/libraries/chain/crosschain_record_evaluate.cpp index adb8b32f..835ec933 100644 --- a/libraries/chain/crosschain_record_evaluate.cpp +++ b/libraries/chain/crosschain_record_evaluate.cpp @@ -2,7 +2,7 @@ #include #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 12c2bf7b..a58bd3d7 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -21,6 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include + #include "db_init.cpp" diff --git a/libraries/chain/database_impl.cpp b/libraries/chain/database_impl.cpp index 2718584d..f2fdff63 100644 --- a/libraries/chain/database_impl.cpp +++ b/libraries/chain/database_impl.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include + #include #include "db_lock_balance.cpp" #include "db_crosschain_trx.cpp" diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index caa39927..3aea8f06 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -24,7 +24,7 @@ #include #include #include -#include + #include #include namespace graphene { namespace chain { diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index a278b680..40730f41 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -25,7 +25,7 @@ #include // these are required to serialize a genesis_state -#include // required for gcc in release mode + // required for gcc in release mode #include namespace graphene { namespace chain { diff --git a/libraries/chain/guard_refund_balance_evaluator.cpp b/libraries/chain/guard_refund_balance_evaluator.cpp index fefb2bab..fc05c750 100644 --- a/libraries/chain/guard_refund_balance_evaluator.cpp +++ b/libraries/chain/guard_refund_balance_evaluator.cpp @@ -2,7 +2,7 @@ #include #include #include -#include + namespace graphene { namespace chain { void_result guard_refund_balance_evaluator::do_apply(const guard_refund_balance_operation& o) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index 0c5691b7..36546f4b 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -24,7 +24,7 @@ #pragma once #include #include -#include + namespace graphene { namespace chain { struct fee_schedule; } } /* diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index cec58b61..acf99b9b 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -36,7 +36,7 @@ #include #include #include -#include + #include #include @@ -64,7 +64,6 @@ namespace graphene { namespace chain { using std::tie; using std::make_pair; - using fc::smart_ref; using fc::variant_object; using fc::variant; using fc::enum_type; diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 8d529d5c..5cefbb37 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -34,7 +34,7 @@ #include #include -#include + namespace graphene { namespace chain { void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_operation& op) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 5f3b3da0..8b013f3e 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 3358e12a..d0e90b47 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -23,7 +23,7 @@ */ #include #include -#include + #include namespace fc { @@ -39,9 +39,6 @@ namespace fc namespace graphene { namespace chain { - typedef fc::smart_ref smart_fee_schedule; - - static smart_fee_schedule tmp; fee_schedule::fee_schedule() { diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/chain/protocol/proposal.cpp index 028e09d2..44b1f546 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/chain/protocol/proposal.cpp @@ -23,7 +23,7 @@ */ #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/referendum.cpp b/libraries/chain/protocol/referendum.cpp index d8bc9f1b..d91ce0b2 100644 --- a/libraries/chain/protocol/referendum.cpp +++ b/libraries/chain/protocol/referendum.cpp @@ -23,7 +23,7 @@ */ #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 7f2f5c3a..5da73bf4 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -25,7 +25,7 @@ #include #include #include -#include + #include #include #include diff --git a/libraries/chain/referendum_evaluator.cpp b/libraries/chain/referendum_evaluator.cpp index 2b5b4d31..3ba556ea 100644 --- a/libraries/chain/referendum_evaluator.cpp +++ b/libraries/chain/referendum_evaluator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include + namespace graphene { namespace chain { diff --git a/libraries/crosschain/crosschain_interface_emu.cpp b/libraries/crosschain/crosschain_interface_emu.cpp index 2847a07e..50a896d4 100644 --- a/libraries/crosschain/crosschain_interface_emu.cpp +++ b/libraries/crosschain/crosschain_interface_emu.cpp @@ -2,7 +2,7 @@ #include #include #include -#include + namespace graphene { namespace crosschain { diff --git a/libraries/crosschain/crosschain_transaction_record_plugin.cpp b/libraries/crosschain/crosschain_transaction_record_plugin.cpp index e16035fd..89137598 100644 --- a/libraries/crosschain/crosschain_transaction_record_plugin.cpp +++ b/libraries/crosschain/crosschain_transaction_record_plugin.cpp @@ -3,7 +3,7 @@ #include #include #include -#include + #include namespace bpo = boost::program_options; namespace graphene { diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index 9fa1e931..913f6606 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -61,7 +61,7 @@ #include #include #include -#include + #define STACK_FILE_NAME "stack" #define STORAGE_FILE_NAME "storage" diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index f8aaadb3..21e8f7d3 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -30,7 +30,7 @@ #include #include -#include // required for gcc in release mode + // required for gcc in release mode #include #include #include diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 49794c24..fbc5d7ca 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -69,7 +69,7 @@ #include #include #include -#include + #include #include diff --git a/libraries/plugins/account_history/account_history_plugin.cpp b/libraries/plugins/account_history/account_history_plugin.cpp index 12dbe6b8..e035d9dd 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -34,7 +34,7 @@ #include #include -#include + #include namespace graphene { namespace account_history { diff --git a/libraries/plugins/debug_witness/debug_api.cpp b/libraries/plugins/debug_witness/debug_api.cpp index 9f9d8262..ee55d26d 100644 --- a/libraries/plugins/debug_witness/debug_api.cpp +++ b/libraries/plugins/debug_witness/debug_api.cpp @@ -2,7 +2,7 @@ #include #include #include -#include + #include diff --git a/libraries/plugins/debug_witness/debug_witness.cpp b/libraries/plugins/debug_witness/debug_witness.cpp index c54524ee..cae9eec1 100644 --- a/libraries/plugins/debug_witness/debug_witness.cpp +++ b/libraries/plugins/debug_witness/debug_witness.cpp @@ -28,7 +28,7 @@ #include -#include + #include #include diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index fa1b8c2f..2d7736dc 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -30,7 +30,7 @@ #include #include #include -#include + namespace graphene { namespace delayed_node { diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 6ec38968..9ca9af70 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -34,7 +34,7 @@ #include #include -#include + namespace graphene { namespace market_history { diff --git a/libraries/plugins/transaction/transaction_plugin.cpp b/libraries/plugins/transaction/transaction_plugin.cpp index 211970f2..253725f3 100644 --- a/libraries/plugins/transaction/transaction_plugin.cpp +++ b/libraries/plugins/transaction/transaction_plugin.cpp @@ -31,7 +31,7 @@ #include #include -#include + #include #include namespace graphene { namespace transaction { diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index c286114a..85784868 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -31,7 +31,7 @@ #include #include #include -#include + #include #include #include diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 7d0227ad..35e429b4 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -46,7 +46,7 @@ #include #include #include -#include + #include #include #include diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index 631fd715..d4ddaa71 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -28,7 +28,7 @@ #include #include #include -#include + #include using namespace graphene::chain; diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 626d0401..0b2bdfe0 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -34,7 +34,7 @@ #include #include #include -#include + #include #include diff --git a/programs/genesis_util/genesis_update.cpp b/programs/genesis_util/genesis_update.cpp index 268608c4..19f8df60 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -30,7 +30,7 @@ #include #include #include -#include + #include #include diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 6691bc1f..5e732ac1 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -37,7 +37,7 @@ #include #include #include -#include + #include #include diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index de071cfc..b0db788d 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -23,7 +23,7 @@ */ #include -#include + #include #include From 41c97405f00452700b4f3f181a48138191ba2f3e Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Thu, 16 Jul 2020 18:11:56 +0800 Subject: [PATCH 14/38] remove \* --- .../fc/include/fc/rpc/api_connection.hpp | 3 +- .../wallet/include/graphene/wallet/wallet.hpp | 978 +----------------- 2 files changed, 5 insertions(+), 976 deletions(-) diff --git a/libraries/fc/include/fc/rpc/api_connection.hpp b/libraries/fc/include/fc/rpc/api_connection.hpp index b7e8c6af..a09102e5 100644 --- a/libraries/fc/include/fc/rpc/api_connection.hpp +++ b/libraries/fc/include/fc/rpc/api_connection.hpp @@ -12,7 +12,7 @@ namespace fc { class api_connection; - + class wallet_api; namespace detail { template class callback_functor @@ -466,6 +466,7 @@ namespace fc { return conn.register_api( *this ); } + template< typename T > api api_base::as() { diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index ad4b1057..5c44072f 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2009,23 +2009,7 @@ class wallet_api full_transaction create_contract_transfer_fee_proposal(const string& proposer,share_type fee_rate, int64_t expiration_time, bool broadcast = false); graphene::chain::optional get_block_for_contract(uint32_t block_num, address contract_address); - // end contract wallet apis - // begin script wallet apis - //std::string add_script(const string& script_path); - //vectorlist_scripts(); - //void remove_script(const string& script_hash); - //bool bind_script_to_event(const string& script_hash, const string& contract, const string& event_name); - //bool remove_event_handle(const string& script_hash, const string& contract, const string& event_name); - // end script wallet apis - /** - * Used to transfer from one set of blinded balances to another - - blind_confirmation blind_transfer_help( string from_key_or_label, - string to_key_or_label, - string amount, - string symbol, - bool broadcast = false, - bool to_temp = false );*/ + full_transaction refund_request(const string& refund_account,const string txid, bool broadcast = false); full_transaction refund_uncombined_transaction(const string senator,const string txid, const int64_t& expiration_time, bool broadcast = false); @@ -2142,19 +2126,7 @@ class wallet_api contract_storage_view get_contract_storage(const address& contract_address, const string& storage_name); vector get_votes(const string& account) const; bool update_seed_node(); - /*void testaaa1() {} - void testaaa2() {} - void testaaa3() {} - void testaaa4() {} - void testaaa5() {} - void testaaa6() {} - void testaaa7() {} - void testaaa8() {} - void testaaa9() {} - void testaaa10() {} - void testaaa11() {} - void testaaa12() {} - void testaaa13() {}*/ + }; } } @@ -2223,951 +2195,7 @@ FC_REFLECT_DERIVED( graphene::wallet::signed_block_with_info, (graphene::chain:: FC_REFLECT( graphene::wallet::operation_detail, (memo)(description)(op) ) - /* - namespace fc { - template - struct vtable : public std::enable_shared_from_this> { - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::help)) help; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::info)) info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::about)) about; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::extra_imp)) extra_imp; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa1)) testaaa1; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa2)) testaaa2; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa3)) testaaa3; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa4)) testaaa4; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa5)) testaaa5; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa6)) testaaa6; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa7)) testaaa7; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa8)) testaaa8; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa9)) testaaa9; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa10)) testaaa10; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa11)) testaaa11; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa12)) testaaa12; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::testaaa13)) testaaa13; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::is_locked)) is_locked; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::is_new)) is_new; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_address_pay_back_balance)) get_address_pay_back_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::obtain_pay_back_balance)) obtain_pay_back_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::obtain_bonus_balance)) obtain_bonus_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_pass_combined_transaction)) senator_pass_combined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_pass_coldhot_combined_transaction)) senator_pass_coldhot_combined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::lock)) lock; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::unlock)) unlock; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::set_password)) set_password; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::dump_private_keys)) dump_private_keys; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::dump_private_key)) dump_private_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_my_accounts)) list_my_accounts; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_addr_balances)) get_addr_balances; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_balances)) get_account_balances; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_assets)) list_assets; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::import_key)) import_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_account)) register_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::upgrade_account)) upgrade_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_account)) wallet_create_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_change_eth_gas_price)) senator_change_eth_gas_price; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_eth_multi_account_trx)) get_eth_multi_account_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_transaction_id)) get_transaction_id; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_asset)) create_asset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_acquire_transaction)) get_acquire_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_asset)) update_asset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_bitasset)) update_bitasset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_asset_feed_producers)) update_asset_feed_producers; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::publish_asset_feed)) publish_asset_feed; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::publish_normal_asset_feed)) publish_normal_asset_feed; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_asset)) get_asset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_asset_imp)) get_asset_imp; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_senator_member)) create_senator_member; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_citizen)) get_citizen; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_senator_member)) get_senator_member; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_citizens)) list_citizens; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_senator_members)) list_senator_members; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_all_senators)) list_all_senators; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_citizen)) create_citizen; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::set_desired_citizen_and_senator_member_count)) set_desired_citizen_and_senator_member_count; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account)) get_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::change_account_name)) change_account_name; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::remove_local_account)) remove_local_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_id)) get_account_id; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_block)) get_block; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::change_acquire_plugin_num)) change_acquire_plugin_num; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_count)) get_account_count; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_history)) get_account_history; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::is_public_key_registered)) is_public_key_registered; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_global_properties)) get_global_properties; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_dynamic_global_properties)) get_dynamic_global_properties; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_object)) get_object; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_private_key)) get_private_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::load_wallet_file)) load_wallet_file; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::save_wallet_file)) save_wallet_file; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_change_acquire_trx)) senator_change_acquire_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::serialize_transaction)) serialize_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::sign_transaction)) sign_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_prototype_operation)) get_prototype_operation; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::propose_senator_pledge_change)) propose_senator_pledge_change; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::propose_pay_back_asset_rate_change)) propose_pay_back_asset_rate_change; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::propose_parameter_change)) propose_parameter_change; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::propose_coin_destory)) propose_coin_destory; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::propose_fee_change)) propose_fee_change; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::approve_proposal)) approve_proposal; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::network_add_nodes)) network_add_nodes; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::network_get_connected_peers)) network_get_connected_peers; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_public_key)) get_public_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_blind_accounts)) get_blind_accounts; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_my_blind_accounts)) get_my_blind_accounts; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_blind_balances)) get_blind_balances; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_blind_account)) create_blind_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::send_coldhot_transfer_with_sign)) send_coldhot_transfer_with_sign; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_coldhot_trx_sig)) get_coldhot_trx_sig; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_to_address)) transfer_to_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_to_account)) transfer_to_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_addr)) get_account_addr; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_proposal)) get_proposal; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_proposal_for_voter)) get_proposal_for_voter; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::lock_balance_to_citizen)) lock_balance_to_citizen; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_lock_balance)) senator_lock_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::foreclose_balance_from_citizen)) foreclose_balance_from_citizen; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_foreclose_balance)) senator_foreclose_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_senator_formal)) update_senator_formal; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_lock_balance)) get_account_lock_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_senator_lock_balance)) get_senator_lock_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_citizen_lock_balance)) get_citizen_lock_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::refund_request)) refund_request; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_cold_hot_uncreate_transaction)) cancel_cold_hot_uncreate_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_from_cold_to_hot)) transfer_from_cold_to_hot; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multi_account_senator)) get_multi_account_senator; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multisig_asset_tx)) get_multisig_asset_tx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::sign_multi_asset_trx)) sign_multi_asset_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_binding_account)) get_binding_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::withdraw_cross_chain_transaction)) withdraw_cross_chain_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::refund_uncombined_transaction)) refund_uncombined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::refund_combined_transaction)) refund_combined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_coldhot_uncombined_transaction)) cancel_coldhot_uncombined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_coldhot_combined_transaction)) cancel_coldhot_combined_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::eth_cancel_fail_transaction)) eth_cancel_fail_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_coldhot_eth_fail_transaction)) cancel_coldhot_eth_fail_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_senator_multi_account)) transfer_senator_multi_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_withdraw_crosschain_without_sign_transaction)) get_withdraw_crosschain_without_sign_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_coldhot_transaction)) get_coldhot_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_crosschain_transaction)) get_crosschain_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_crosschain_transaction_by_block_num)) get_crosschain_transaction_by_block_num; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_coldhot_transaction_by_blocknum)) get_coldhot_transaction_by_blocknum; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multi_address_obj)) get_multi_address_obj; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_asset)) wallet_create_asset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_erc_asset)) wallet_create_erc_asset; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_crosschain_symbol)) create_crosschain_symbol; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_crosschain_symbol_cold)) create_crosschain_symbol_cold; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::bind_tunnel_account)) bind_tunnel_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::unbind_tunnel_account)) unbind_tunnel_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_asset_private_keys)) update_asset_private_keys; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_asset_private_keys_with_brain_key)) update_asset_private_keys_with_brain_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::update_asset_private_with_coldkeys)) update_asset_private_with_coldkeys; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multisig_account_pair_by_id)) get_multisig_account_pair_by_id; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multisig_account_pair)) get_multisig_account_pair; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_sign_crosschain_transaction)) senator_sign_crosschain_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_sign_coldhot_transaction)) senator_sign_coldhot_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_sign_eths_multi_account_create_trx)) senator_sign_eths_multi_account_create_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_sign_eths_final_trx)) senator_sign_eths_final_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_changer_eth_singer_trx)) senator_changer_eth_singer_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_changer_eth_coldhot_singer_trx)) senator_changer_eth_coldhot_singer_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_sign_eths_coldhot_final_trx)) senator_sign_eths_coldhot_final_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::account_change_for_crosschain)) account_change_for_crosschain; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_current_multi_address_obj)) get_current_multi_address_obj; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_current_multi_address)) get_current_multi_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_contract)) register_contract; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_native_contract)) register_native_contract; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_contract_like)) register_contract_like; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::invoke_contract)) invoke_contract; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::invoke_contract_offline)) invoke_contract_offline; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::upgrade_contract)) upgrade_contract; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_info)) get_contract_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_simple_contract_info)) get_simple_contract_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_to_contract)) transfer_to_contract; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_balance)) get_contract_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_addresses_by_owner)) get_contract_addresses_by_owner; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contracts_by_owner)) get_contracts_by_owner; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contracts_hash_entry_by_owner)) get_contracts_hash_entry_by_owner; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_events)) get_contract_events; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_events_in_range)) get_contract_events_in_range; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_history)) get_contract_history; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_guarantee_order)) create_guarantee_order; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_guarantee_order)) list_guarantee_order; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::set_guarantee_id)) set_guarantee_id; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_guarantee_order)) cancel_guarantee_order; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::invoke_contract_testing)) invoke_contract_testing; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_to_contract_testing)) transfer_to_contract_testing; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_contract_testing)) register_contract_testing; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::register_native_contract_testing)) register_native_contract_testing; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::upgrade_contract_testing)) upgrade_contract_testing; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_registered)) get_contract_registered; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_storage_changed)) get_contract_storage_changed; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_contract_transfer_fee_proposal)) create_contract_transfer_fee_proposal; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_transaction)) get_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_transactions)) list_transactions; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::dump_crosschain_private_key)) dump_crosschain_private_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::dump_crosschain_private_keys)) dump_crosschain_private_keys; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_crosschain_symbol)) wallet_create_crosschain_symbol; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_crosschain_symbol_with_brain_key)) wallet_create_crosschain_symbol_with_brain_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::import_crosschain_key)) import_crosschain_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::decoderawtransaction)) decoderawtransaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::createrawtransaction)) createrawtransaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::signrawtransaction)) signrawtransaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_my_guarantee_order)) get_my_guarantee_order; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_contract_invoke_object)) get_contract_invoke_object; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_guarantee_order)) get_guarantee_order; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_appointed_publisher)) senator_appointed_publisher; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_appointed_crosschain_fee)) senator_appointed_crosschain_fee; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::remove_guarantee_id)) remove_guarantee_id; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::network_get_info)) network_get_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::start_citizen)) start_citizen; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_crosschain_transaction)) get_account_crosschain_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::witness_node_stop)) witness_node_stop; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_bonus_balance)) get_bonus_balance; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_appointed_lockbalance_senator)) senator_appointed_lockbalance_senator; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_citizen_lockbalance_info)) get_citizen_lockbalance_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_cancel_publisher)) senator_cancel_publisher; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_determine_withdraw_deposit)) senator_determine_withdraw_deposit; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::lightwallet_broadcast)) lightwallet_broadcast; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::lightwallet_get_refblock_info)) lightwallet_get_refblock_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::create_multisignature_address)) create_multisignature_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_first_contract_address)) get_first_contract_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_pubkey_from_priv)) get_pubkey_from_priv; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::sign_multisig_trx)) sign_multisig_trx; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::senator_determine_block_payment)) senator_determine_block_payment; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::transfer_from_to_address)) transfer_from_to_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::combine_transaction)) combine_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_multisig_address)) get_multisig_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::set_citizen_pledge_pay_back_rate)) set_citizen_pledge_pay_back_rate; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::list_active_citizens)) list_active_citizens; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::decode_multisig_transaction)) decode_multisig_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_pubkey_from_account)) get_pubkey_from_account; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_eth_signer)) get_eth_signer; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::citizen_referendum_for_senator)) citizen_referendum_for_senator; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_referendum_for_voter)) get_referendum_for_voter; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::referendum_accelerate_pledge)) referendum_accelerate_pledge; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::approve_referendum)) approve_referendum; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::proposal_block_address)) proposal_block_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::proposal_cancel_block_address)) proposal_cancel_block_address; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::decrypt_coldkeys)) decrypt_coldkeys; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_ntp_info)) get_ntp_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::ntp_update_time)) ntp_update_time; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_account_by_addr)) get_account_by_addr; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::start_mining)) start_mining; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::foreclose_balance_from_citizens)) foreclose_balance_from_citizens; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::lock_balance_to_citizens)) lock_balance_to_citizens; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::cancel_eth_sign_transaction)) cancel_eth_sign_transaction; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::dump_brain_key_usage_info)) dump_brain_key_usage_info; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::wallet_create_account_with_brain_key)) wallet_create_account_with_brain_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::derive_wif_key)) derive_wif_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::set_brain_key)) set_brain_key; - decltype(Transform::functor((graphene::wallet::wallet_api*)nullptr, &graphene::wallet::wallet_api::get_pending_transactions)) get_pending_transactions; - template - void visit_other(Visitor&& v) { - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(help), help, &OtherType::help); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(info), info, &OtherType::info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(about), about, &OtherType::about); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(extra_imp), extra_imp, &OtherType::extra_imp); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa1), testaaa1, &OtherType::testaaa1); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa2), testaaa2, &OtherType::testaaa2); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa3), testaaa3, &OtherType::testaaa3); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa4), testaaa4, &OtherType::testaaa4); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa5), testaaa5, &OtherType::testaaa5); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa6), testaaa6, &OtherType::testaaa6); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa7), testaaa7, &OtherType::testaaa7); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa8), testaaa8, &OtherType::testaaa8); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa9), testaaa9, &OtherType::testaaa9); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa10), testaaa10, &OtherType::testaaa10); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa11), testaaa11, &OtherType::testaaa11); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa12), testaaa12, &OtherType::testaaa12); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(testaaa13), testaaa13, &OtherType::testaaa13); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(is_locked), is_locked, &OtherType::is_locked); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(is_new), is_new, &OtherType::is_new); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_address_pay_back_balance), get_address_pay_back_balance, &OtherType::get_address_pay_back_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(obtain_pay_back_balance), obtain_pay_back_balance, &OtherType::obtain_pay_back_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(obtain_bonus_balance), obtain_bonus_balance, &OtherType::obtain_bonus_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_pass_combined_transaction), senator_pass_combined_transaction, &OtherType::senator_pass_combined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_pass_coldhot_combined_transaction), senator_pass_coldhot_combined_transaction, &OtherType::senator_pass_coldhot_combined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(lock), lock, &OtherType::lock); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(unlock), unlock, &OtherType::unlock); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(set_password), set_password, &OtherType::set_password); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(dump_private_keys), dump_private_keys, &OtherType::dump_private_keys); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(dump_private_key), dump_private_key, &OtherType::dump_private_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_my_accounts), list_my_accounts, &OtherType::list_my_accounts); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_addr_balances), get_addr_balances, &OtherType::get_addr_balances); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_balances), get_account_balances, &OtherType::get_account_balances); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_assets), list_assets, &OtherType::list_assets); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(import_key), import_key, &OtherType::import_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_account), register_account, &OtherType::register_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(upgrade_account), upgrade_account, &OtherType::upgrade_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_account), wallet_create_account, &OtherType::wallet_create_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_change_eth_gas_price), senator_change_eth_gas_price, &OtherType::senator_change_eth_gas_price); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_eth_multi_account_trx), get_eth_multi_account_trx, &OtherType::get_eth_multi_account_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_transaction_id), get_transaction_id, &OtherType::get_transaction_id); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_asset), create_asset, &OtherType::create_asset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_acquire_transaction), get_acquire_transaction, &OtherType::get_acquire_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_asset), update_asset, &OtherType::update_asset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_bitasset), update_bitasset, &OtherType::update_bitasset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_asset_feed_producers), update_asset_feed_producers, &OtherType::update_asset_feed_producers); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(publish_asset_feed), publish_asset_feed, &OtherType::publish_asset_feed); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(publish_normal_asset_feed), publish_normal_asset_feed, &OtherType::publish_normal_asset_feed); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_asset), get_asset, &OtherType::get_asset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_asset_imp), get_asset_imp, &OtherType::get_asset_imp); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_senator_member), create_senator_member, &OtherType::create_senator_member); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_citizen), get_citizen, &OtherType::get_citizen); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_senator_member), get_senator_member, &OtherType::get_senator_member); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_citizens), list_citizens, &OtherType::list_citizens); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_senator_members), list_senator_members, &OtherType::list_senator_members); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_all_senators), list_all_senators, &OtherType::list_all_senators); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_citizen), create_citizen, &OtherType::create_citizen); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(set_desired_citizen_and_senator_member_count), set_desired_citizen_and_senator_member_count, &OtherType::set_desired_citizen_and_senator_member_count); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account), get_account, &OtherType::get_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(change_account_name), change_account_name, &OtherType::change_account_name); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(remove_local_account), remove_local_account, &OtherType::remove_local_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_id), get_account_id, &OtherType::get_account_id); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_block), get_block, &OtherType::get_block); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(change_acquire_plugin_num), change_acquire_plugin_num, &OtherType::change_acquire_plugin_num); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_count), get_account_count, &OtherType::get_account_count); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_history), get_account_history, &OtherType::get_account_history); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(is_public_key_registered), is_public_key_registered, &OtherType::is_public_key_registered); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_global_properties), get_global_properties, &OtherType::get_global_properties); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_dynamic_global_properties), get_dynamic_global_properties, &OtherType::get_dynamic_global_properties); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_object), get_object, &OtherType::get_object); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_private_key), get_private_key, &OtherType::get_private_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(load_wallet_file), load_wallet_file, &OtherType::load_wallet_file); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(save_wallet_file), save_wallet_file, &OtherType::save_wallet_file); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_change_acquire_trx), senator_change_acquire_trx, &OtherType::senator_change_acquire_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(serialize_transaction), serialize_transaction, &OtherType::serialize_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(sign_transaction), sign_transaction, &OtherType::sign_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_prototype_operation), get_prototype_operation, &OtherType::get_prototype_operation); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(propose_senator_pledge_change), propose_senator_pledge_change, &OtherType::propose_senator_pledge_change); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(propose_pay_back_asset_rate_change), propose_pay_back_asset_rate_change, &OtherType::propose_pay_back_asset_rate_change); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(propose_parameter_change), propose_parameter_change, &OtherType::propose_parameter_change); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(propose_coin_destory), propose_coin_destory, &OtherType::propose_coin_destory); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(propose_fee_change), propose_fee_change, &OtherType::propose_fee_change); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(approve_proposal), approve_proposal, &OtherType::approve_proposal); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(network_add_nodes), network_add_nodes, &OtherType::network_add_nodes); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(network_get_connected_peers), network_get_connected_peers, &OtherType::network_get_connected_peers); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_public_key), get_public_key, &OtherType::get_public_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_blind_accounts), get_blind_accounts, &OtherType::get_blind_accounts); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_my_blind_accounts), get_my_blind_accounts, &OtherType::get_my_blind_accounts); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_blind_balances), get_blind_balances, &OtherType::get_blind_balances); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_blind_account), create_blind_account, &OtherType::create_blind_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(send_coldhot_transfer_with_sign), send_coldhot_transfer_with_sign, &OtherType::send_coldhot_transfer_with_sign); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_coldhot_trx_sig), get_coldhot_trx_sig, &OtherType::get_coldhot_trx_sig); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_to_address), transfer_to_address, &OtherType::transfer_to_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_to_account), transfer_to_account, &OtherType::transfer_to_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_addr), get_account_addr, &OtherType::get_account_addr); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_proposal), get_proposal, &OtherType::get_proposal); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_proposal_for_voter), get_proposal_for_voter, &OtherType::get_proposal_for_voter); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(lock_balance_to_citizen), lock_balance_to_citizen, &OtherType::lock_balance_to_citizen); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_lock_balance), senator_lock_balance, &OtherType::senator_lock_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(foreclose_balance_from_citizen), foreclose_balance_from_citizen, &OtherType::foreclose_balance_from_citizen); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_foreclose_balance), senator_foreclose_balance, &OtherType::senator_foreclose_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_senator_formal), update_senator_formal, &OtherType::update_senator_formal); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_lock_balance), get_account_lock_balance, &OtherType::get_account_lock_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_senator_lock_balance), get_senator_lock_balance, &OtherType::get_senator_lock_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_citizen_lock_balance), get_citizen_lock_balance, &OtherType::get_citizen_lock_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(refund_request), refund_request, &OtherType::refund_request); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_cold_hot_uncreate_transaction), cancel_cold_hot_uncreate_transaction, &OtherType::cancel_cold_hot_uncreate_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_from_cold_to_hot), transfer_from_cold_to_hot, &OtherType::transfer_from_cold_to_hot); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multi_account_senator), get_multi_account_senator, &OtherType::get_multi_account_senator); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multisig_asset_tx), get_multisig_asset_tx, &OtherType::get_multisig_asset_tx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(sign_multi_asset_trx), sign_multi_asset_trx, &OtherType::sign_multi_asset_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_binding_account), get_binding_account, &OtherType::get_binding_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(withdraw_cross_chain_transaction), withdraw_cross_chain_transaction, &OtherType::withdraw_cross_chain_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(refund_uncombined_transaction), refund_uncombined_transaction, &OtherType::refund_uncombined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(refund_combined_transaction), refund_combined_transaction, &OtherType::refund_combined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_coldhot_uncombined_transaction), cancel_coldhot_uncombined_transaction, &OtherType::cancel_coldhot_uncombined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_coldhot_combined_transaction), cancel_coldhot_combined_transaction, &OtherType::cancel_coldhot_combined_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(eth_cancel_fail_transaction), eth_cancel_fail_transaction, &OtherType::eth_cancel_fail_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_coldhot_eth_fail_transaction), cancel_coldhot_eth_fail_transaction, &OtherType::cancel_coldhot_eth_fail_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_senator_multi_account), transfer_senator_multi_account, &OtherType::transfer_senator_multi_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_withdraw_crosschain_without_sign_transaction), get_withdraw_crosschain_without_sign_transaction, &OtherType::get_withdraw_crosschain_without_sign_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_coldhot_transaction), get_coldhot_transaction, &OtherType::get_coldhot_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_crosschain_transaction), get_crosschain_transaction, &OtherType::get_crosschain_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_crosschain_transaction_by_block_num), get_crosschain_transaction_by_block_num, &OtherType::get_crosschain_transaction_by_block_num); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_coldhot_transaction_by_blocknum), get_coldhot_transaction_by_blocknum, &OtherType::get_coldhot_transaction_by_blocknum); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multi_address_obj), get_multi_address_obj, &OtherType::get_multi_address_obj); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_asset), wallet_create_asset, &OtherType::wallet_create_asset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_erc_asset), wallet_create_erc_asset, &OtherType::wallet_create_erc_asset); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_crosschain_symbol), create_crosschain_symbol, &OtherType::create_crosschain_symbol); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_crosschain_symbol_cold), create_crosschain_symbol_cold, &OtherType::create_crosschain_symbol_cold); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(bind_tunnel_account), bind_tunnel_account, &OtherType::bind_tunnel_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(unbind_tunnel_account), unbind_tunnel_account, &OtherType::unbind_tunnel_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_asset_private_keys), update_asset_private_keys, &OtherType::update_asset_private_keys); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_asset_private_keys_with_brain_key), update_asset_private_keys_with_brain_key, &OtherType::update_asset_private_keys_with_brain_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(update_asset_private_with_coldkeys), update_asset_private_with_coldkeys, &OtherType::update_asset_private_with_coldkeys); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multisig_account_pair_by_id), get_multisig_account_pair_by_id, &OtherType::get_multisig_account_pair_by_id); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multisig_account_pair), get_multisig_account_pair, &OtherType::get_multisig_account_pair); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_sign_crosschain_transaction), senator_sign_crosschain_transaction, &OtherType::senator_sign_crosschain_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_sign_coldhot_transaction), senator_sign_coldhot_transaction, &OtherType::senator_sign_coldhot_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_sign_eths_multi_account_create_trx), senator_sign_eths_multi_account_create_trx, &OtherType::senator_sign_eths_multi_account_create_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_sign_eths_final_trx), senator_sign_eths_final_trx, &OtherType::senator_sign_eths_final_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_changer_eth_singer_trx), senator_changer_eth_singer_trx, &OtherType::senator_changer_eth_singer_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_changer_eth_coldhot_singer_trx), senator_changer_eth_coldhot_singer_trx, &OtherType::senator_changer_eth_coldhot_singer_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_sign_eths_coldhot_final_trx), senator_sign_eths_coldhot_final_trx, &OtherType::senator_sign_eths_coldhot_final_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(account_change_for_crosschain), account_change_for_crosschain, &OtherType::account_change_for_crosschain); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_current_multi_address_obj), get_current_multi_address_obj, &OtherType::get_current_multi_address_obj); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_current_multi_address), get_current_multi_address, &OtherType::get_current_multi_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_contract), register_contract, &OtherType::register_contract); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_native_contract), register_native_contract, &OtherType::register_native_contract); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_contract_like), register_contract_like, &OtherType::register_contract_like); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(invoke_contract), invoke_contract, &OtherType::invoke_contract); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(invoke_contract_offline), invoke_contract_offline, &OtherType::invoke_contract_offline); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(upgrade_contract), upgrade_contract, &OtherType::upgrade_contract); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_info), get_contract_info, &OtherType::get_contract_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_simple_contract_info), get_simple_contract_info, &OtherType::get_simple_contract_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_to_contract), transfer_to_contract, &OtherType::transfer_to_contract); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_balance), get_contract_balance, &OtherType::get_contract_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_addresses_by_owner), get_contract_addresses_by_owner, &OtherType::get_contract_addresses_by_owner); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contracts_by_owner), get_contracts_by_owner, &OtherType::get_contracts_by_owner); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contracts_hash_entry_by_owner), get_contracts_hash_entry_by_owner, &OtherType::get_contracts_hash_entry_by_owner); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_events), get_contract_events, &OtherType::get_contract_events); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_events_in_range), get_contract_events_in_range, &OtherType::get_contract_events_in_range); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_history), get_contract_history, &OtherType::get_contract_history); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_guarantee_order), create_guarantee_order, &OtherType::create_guarantee_order); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_guarantee_order), list_guarantee_order, &OtherType::list_guarantee_order); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(set_guarantee_id), set_guarantee_id, &OtherType::set_guarantee_id); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_guarantee_order), cancel_guarantee_order, &OtherType::cancel_guarantee_order); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(invoke_contract_testing), invoke_contract_testing, &OtherType::invoke_contract_testing); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_to_contract_testing), transfer_to_contract_testing, &OtherType::transfer_to_contract_testing); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_contract_testing), register_contract_testing, &OtherType::register_contract_testing); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(register_native_contract_testing), register_native_contract_testing, &OtherType::register_native_contract_testing); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(upgrade_contract_testing), upgrade_contract_testing, &OtherType::upgrade_contract_testing); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_registered), get_contract_registered, &OtherType::get_contract_registered); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_storage_changed), get_contract_storage_changed, &OtherType::get_contract_storage_changed); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_contract_transfer_fee_proposal), create_contract_transfer_fee_proposal, &OtherType::create_contract_transfer_fee_proposal); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_transaction), get_transaction, &OtherType::get_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_transactions), list_transactions, &OtherType::list_transactions); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(dump_crosschain_private_key), dump_crosschain_private_key, &OtherType::dump_crosschain_private_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(dump_crosschain_private_keys), dump_crosschain_private_keys, &OtherType::dump_crosschain_private_keys); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_crosschain_symbol), wallet_create_crosschain_symbol, &OtherType::wallet_create_crosschain_symbol); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_crosschain_symbol_with_brain_key), wallet_create_crosschain_symbol_with_brain_key, &OtherType::wallet_create_crosschain_symbol_with_brain_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(import_crosschain_key), import_crosschain_key, &OtherType::import_crosschain_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(decoderawtransaction), decoderawtransaction, &OtherType::decoderawtransaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(createrawtransaction), createrawtransaction, &OtherType::createrawtransaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(signrawtransaction), signrawtransaction, &OtherType::signrawtransaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_my_guarantee_order), get_my_guarantee_order, &OtherType::get_my_guarantee_order); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_contract_invoke_object), get_contract_invoke_object, &OtherType::get_contract_invoke_object); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_guarantee_order), get_guarantee_order, &OtherType::get_guarantee_order); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_appointed_publisher), senator_appointed_publisher, &OtherType::senator_appointed_publisher); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_appointed_crosschain_fee), senator_appointed_crosschain_fee, &OtherType::senator_appointed_crosschain_fee); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(remove_guarantee_id), remove_guarantee_id, &OtherType::remove_guarantee_id); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(network_get_info), network_get_info, &OtherType::network_get_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(start_citizen), start_citizen, &OtherType::start_citizen); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_crosschain_transaction), get_account_crosschain_transaction, &OtherType::get_account_crosschain_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(witness_node_stop), witness_node_stop, &OtherType::witness_node_stop); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_bonus_balance), get_bonus_balance, &OtherType::get_bonus_balance); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_appointed_lockbalance_senator), senator_appointed_lockbalance_senator, &OtherType::senator_appointed_lockbalance_senator); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_citizen_lockbalance_info), get_citizen_lockbalance_info, &OtherType::get_citizen_lockbalance_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_cancel_publisher), senator_cancel_publisher, &OtherType::senator_cancel_publisher); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_determine_withdraw_deposit), senator_determine_withdraw_deposit, &OtherType::senator_determine_withdraw_deposit); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(lightwallet_broadcast), lightwallet_broadcast, &OtherType::lightwallet_broadcast); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(lightwallet_get_refblock_info), lightwallet_get_refblock_info, &OtherType::lightwallet_get_refblock_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(create_multisignature_address), create_multisignature_address, &OtherType::create_multisignature_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_first_contract_address), get_first_contract_address, &OtherType::get_first_contract_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_pubkey_from_priv), get_pubkey_from_priv, &OtherType::get_pubkey_from_priv); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(sign_multisig_trx), sign_multisig_trx, &OtherType::sign_multisig_trx); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(senator_determine_block_payment), senator_determine_block_payment, &OtherType::senator_determine_block_payment); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(transfer_from_to_address), transfer_from_to_address, &OtherType::transfer_from_to_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(combine_transaction), combine_transaction, &OtherType::combine_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_multisig_address), get_multisig_address, &OtherType::get_multisig_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(set_citizen_pledge_pay_back_rate), set_citizen_pledge_pay_back_rate, &OtherType::set_citizen_pledge_pay_back_rate); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(list_active_citizens), list_active_citizens, &OtherType::list_active_citizens); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(decode_multisig_transaction), decode_multisig_transaction, &OtherType::decode_multisig_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_pubkey_from_account), get_pubkey_from_account, &OtherType::get_pubkey_from_account); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_eth_signer), get_eth_signer, &OtherType::get_eth_signer); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(citizen_referendum_for_senator), citizen_referendum_for_senator, &OtherType::citizen_referendum_for_senator); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_referendum_for_voter), get_referendum_for_voter, &OtherType::get_referendum_for_voter); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(referendum_accelerate_pledge), referendum_accelerate_pledge, &OtherType::referendum_accelerate_pledge); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(approve_referendum), approve_referendum, &OtherType::approve_referendum); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(proposal_block_address), proposal_block_address, &OtherType::proposal_block_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(proposal_cancel_block_address), proposal_cancel_block_address, &OtherType::proposal_cancel_block_address); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(decrypt_coldkeys), decrypt_coldkeys, &OtherType::decrypt_coldkeys); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_ntp_info), get_ntp_info, &OtherType::get_ntp_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(ntp_update_time), ntp_update_time, &OtherType::ntp_update_time); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_account_by_addr), get_account_by_addr, &OtherType::get_account_by_addr); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(start_mining), start_mining, &OtherType::start_mining); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(foreclose_balance_from_citizens), foreclose_balance_from_citizens, &OtherType::foreclose_balance_from_citizens); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(lock_balance_to_citizens), lock_balance_to_citizens, &OtherType::lock_balance_to_citizens); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(cancel_eth_sign_transaction), cancel_eth_sign_transaction, &OtherType::cancel_eth_sign_transaction); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(dump_brain_key_usage_info), dump_brain_key_usage_info, &OtherType::dump_brain_key_usage_info); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(wallet_create_account_with_brain_key), wallet_create_account_with_brain_key, &OtherType::wallet_create_account_with_brain_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(derive_wif_key), derive_wif_key, &OtherType::derive_wif_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(set_brain_key), set_brain_key, &OtherType::set_brain_key); } - { typedef typename Visitor::other_type OtherType; - v(BOOST_PP_STRINGIZE(get_pending_transactions), get_pending_transactions, &OtherType::get_pending_transactions); } - } - template - void visit(Visitor&& v) { - v(BOOST_PP_STRINGIZE(help), help); - v(BOOST_PP_STRINGIZE(info), info); - v(BOOST_PP_STRINGIZE(about), about); - v(BOOST_PP_STRINGIZE(extra_imp), extra_imp); - v(BOOST_PP_STRINGIZE(testaaa1), testaaa1); - v(BOOST_PP_STRINGIZE(testaaa2), testaaa2); - v(BOOST_PP_STRINGIZE(testaaa3), testaaa3); - v(BOOST_PP_STRINGIZE(testaaa4), testaaa4); - v(BOOST_PP_STRINGIZE(testaaa5), testaaa5); - v(BOOST_PP_STRINGIZE(testaaa6), testaaa6); - v(BOOST_PP_STRINGIZE(testaaa7), testaaa7); - v(BOOST_PP_STRINGIZE(testaaa8), testaaa8); - v(BOOST_PP_STRINGIZE(testaaa9), testaaa9); - v(BOOST_PP_STRINGIZE(testaaa10), testaaa10); - v(BOOST_PP_STRINGIZE(testaaa11), testaaa11); - v(BOOST_PP_STRINGIZE(testaaa12), testaaa12); - v(BOOST_PP_STRINGIZE(testaaa13), testaaa13); - v(BOOST_PP_STRINGIZE(is_locked), is_locked); - v(BOOST_PP_STRINGIZE(is_new), is_new); - v(BOOST_PP_STRINGIZE(get_address_pay_back_balance), get_address_pay_back_balance); - v(BOOST_PP_STRINGIZE(obtain_pay_back_balance), obtain_pay_back_balance); - v(BOOST_PP_STRINGIZE(obtain_bonus_balance), obtain_bonus_balance); - v(BOOST_PP_STRINGIZE(senator_pass_combined_transaction), senator_pass_combined_transaction); - v(BOOST_PP_STRINGIZE(senator_pass_coldhot_combined_transaction), senator_pass_coldhot_combined_transaction); - v(BOOST_PP_STRINGIZE(lock), lock); - v(BOOST_PP_STRINGIZE(unlock), unlock); - v(BOOST_PP_STRINGIZE(set_password), set_password); - v(BOOST_PP_STRINGIZE(dump_private_keys), dump_private_keys); - v(BOOST_PP_STRINGIZE(dump_private_key), dump_private_key); - v(BOOST_PP_STRINGIZE(list_my_accounts), list_my_accounts); - v(BOOST_PP_STRINGIZE(get_addr_balances), get_addr_balances); - v(BOOST_PP_STRINGIZE(get_account_balances), get_account_balances); - v(BOOST_PP_STRINGIZE(list_assets), list_assets); - v(BOOST_PP_STRINGIZE(import_key), import_key); - v(BOOST_PP_STRINGIZE(register_account), register_account); - v(BOOST_PP_STRINGIZE(upgrade_account), upgrade_account); - v(BOOST_PP_STRINGIZE(wallet_create_account), wallet_create_account); - v(BOOST_PP_STRINGIZE(senator_change_eth_gas_price), senator_change_eth_gas_price); - v(BOOST_PP_STRINGIZE(get_eth_multi_account_trx), get_eth_multi_account_trx); - v(BOOST_PP_STRINGIZE(get_transaction_id), get_transaction_id); - v(BOOST_PP_STRINGIZE(create_asset), create_asset); - v(BOOST_PP_STRINGIZE(get_acquire_transaction), get_acquire_transaction); - v(BOOST_PP_STRINGIZE(update_asset), update_asset); - v(BOOST_PP_STRINGIZE(update_bitasset), update_bitasset); - v(BOOST_PP_STRINGIZE(update_asset_feed_producers), update_asset_feed_producers); - v(BOOST_PP_STRINGIZE(publish_asset_feed), publish_asset_feed); - v(BOOST_PP_STRINGIZE(publish_normal_asset_feed), publish_normal_asset_feed); - v(BOOST_PP_STRINGIZE(get_asset), get_asset); - v(BOOST_PP_STRINGIZE(get_asset_imp), get_asset_imp); - v(BOOST_PP_STRINGIZE(create_senator_member), create_senator_member); - v(BOOST_PP_STRINGIZE(get_citizen), get_citizen); - v(BOOST_PP_STRINGIZE(get_senator_member), get_senator_member); - v(BOOST_PP_STRINGIZE(list_citizens), list_citizens); - v(BOOST_PP_STRINGIZE(list_senator_members), list_senator_members); - v(BOOST_PP_STRINGIZE(list_all_senators), list_all_senators); - v(BOOST_PP_STRINGIZE(create_citizen), create_citizen); - v(BOOST_PP_STRINGIZE(set_desired_citizen_and_senator_member_count), set_desired_citizen_and_senator_member_count); - v(BOOST_PP_STRINGIZE(get_account), get_account); - v(BOOST_PP_STRINGIZE(change_account_name), change_account_name); - v(BOOST_PP_STRINGIZE(remove_local_account), remove_local_account); - v(BOOST_PP_STRINGIZE(get_account_id), get_account_id); - v(BOOST_PP_STRINGIZE(get_block), get_block); - v(BOOST_PP_STRINGIZE(change_acquire_plugin_num), change_acquire_plugin_num); - v(BOOST_PP_STRINGIZE(get_account_count), get_account_count); - v(BOOST_PP_STRINGIZE(get_account_history), get_account_history); - v(BOOST_PP_STRINGIZE(is_public_key_registered), is_public_key_registered); - v(BOOST_PP_STRINGIZE(get_global_properties), get_global_properties); - v(BOOST_PP_STRINGIZE(get_dynamic_global_properties), get_dynamic_global_properties); - v(BOOST_PP_STRINGIZE(get_object), get_object); - v(BOOST_PP_STRINGIZE(get_private_key), get_private_key); - v(BOOST_PP_STRINGIZE(load_wallet_file), load_wallet_file); - v(BOOST_PP_STRINGIZE(save_wallet_file), save_wallet_file); - v(BOOST_PP_STRINGIZE(senator_change_acquire_trx), senator_change_acquire_trx); - v(BOOST_PP_STRINGIZE(serialize_transaction), serialize_transaction); - v(BOOST_PP_STRINGIZE(sign_transaction), sign_transaction); - v(BOOST_PP_STRINGIZE(get_prototype_operation), get_prototype_operation); - v(BOOST_PP_STRINGIZE(propose_senator_pledge_change), propose_senator_pledge_change); - v(BOOST_PP_STRINGIZE(propose_pay_back_asset_rate_change), propose_pay_back_asset_rate_change); - v(BOOST_PP_STRINGIZE(propose_parameter_change), propose_parameter_change); - v(BOOST_PP_STRINGIZE(propose_coin_destory), propose_coin_destory); - v(BOOST_PP_STRINGIZE(propose_fee_change), propose_fee_change); - v(BOOST_PP_STRINGIZE(approve_proposal), approve_proposal); - v(BOOST_PP_STRINGIZE(network_add_nodes), network_add_nodes); - v(BOOST_PP_STRINGIZE(network_get_connected_peers), network_get_connected_peers); - v(BOOST_PP_STRINGIZE(get_public_key), get_public_key); - v(BOOST_PP_STRINGIZE(get_blind_accounts), get_blind_accounts); - v(BOOST_PP_STRINGIZE(get_my_blind_accounts), get_my_blind_accounts); - v(BOOST_PP_STRINGIZE(get_blind_balances), get_blind_balances); - v(BOOST_PP_STRINGIZE(create_blind_account), create_blind_account); - v(BOOST_PP_STRINGIZE(send_coldhot_transfer_with_sign), send_coldhot_transfer_with_sign); - v(BOOST_PP_STRINGIZE(get_coldhot_trx_sig), get_coldhot_trx_sig); - v(BOOST_PP_STRINGIZE(transfer_to_address), transfer_to_address); - v(BOOST_PP_STRINGIZE(transfer_to_account), transfer_to_account); - v(BOOST_PP_STRINGIZE(get_account_addr), get_account_addr); - v(BOOST_PP_STRINGIZE(get_proposal), get_proposal); - v(BOOST_PP_STRINGIZE(get_proposal_for_voter), get_proposal_for_voter); - v(BOOST_PP_STRINGIZE(lock_balance_to_citizen), lock_balance_to_citizen); - v(BOOST_PP_STRINGIZE(senator_lock_balance), senator_lock_balance); - v(BOOST_PP_STRINGIZE(foreclose_balance_from_citizen), foreclose_balance_from_citizen); - v(BOOST_PP_STRINGIZE(senator_foreclose_balance), senator_foreclose_balance); - v(BOOST_PP_STRINGIZE(update_senator_formal), update_senator_formal); - v(BOOST_PP_STRINGIZE(get_account_lock_balance), get_account_lock_balance); - v(BOOST_PP_STRINGIZE(get_senator_lock_balance), get_senator_lock_balance); - v(BOOST_PP_STRINGIZE(get_citizen_lock_balance), get_citizen_lock_balance); - v(BOOST_PP_STRINGIZE(refund_request), refund_request); - v(BOOST_PP_STRINGIZE(cancel_cold_hot_uncreate_transaction), cancel_cold_hot_uncreate_transaction); - v(BOOST_PP_STRINGIZE(transfer_from_cold_to_hot), transfer_from_cold_to_hot); - v(BOOST_PP_STRINGIZE(get_multi_account_senator), get_multi_account_senator); - v(BOOST_PP_STRINGIZE(get_multisig_asset_tx), get_multisig_asset_tx); - v(BOOST_PP_STRINGIZE(sign_multi_asset_trx), sign_multi_asset_trx); - v(BOOST_PP_STRINGIZE(get_binding_account), get_binding_account); - v(BOOST_PP_STRINGIZE(withdraw_cross_chain_transaction), withdraw_cross_chain_transaction); - v(BOOST_PP_STRINGIZE(refund_uncombined_transaction), refund_uncombined_transaction); - v(BOOST_PP_STRINGIZE(refund_combined_transaction), refund_combined_transaction); - v(BOOST_PP_STRINGIZE(cancel_coldhot_uncombined_transaction), cancel_coldhot_uncombined_transaction); - v(BOOST_PP_STRINGIZE(cancel_coldhot_combined_transaction), cancel_coldhot_combined_transaction); - v(BOOST_PP_STRINGIZE(eth_cancel_fail_transaction), eth_cancel_fail_transaction); - v(BOOST_PP_STRINGIZE(cancel_coldhot_eth_fail_transaction), cancel_coldhot_eth_fail_transaction); - v(BOOST_PP_STRINGIZE(transfer_senator_multi_account), transfer_senator_multi_account); - v(BOOST_PP_STRINGIZE(get_withdraw_crosschain_without_sign_transaction), get_withdraw_crosschain_without_sign_transaction); - v(BOOST_PP_STRINGIZE(get_coldhot_transaction), get_coldhot_transaction); - v(BOOST_PP_STRINGIZE(get_crosschain_transaction), get_crosschain_transaction); - v(BOOST_PP_STRINGIZE(get_crosschain_transaction_by_block_num), get_crosschain_transaction_by_block_num); - v(BOOST_PP_STRINGIZE(get_coldhot_transaction_by_blocknum), get_coldhot_transaction_by_blocknum); - v(BOOST_PP_STRINGIZE(get_multi_address_obj), get_multi_address_obj); - v(BOOST_PP_STRINGIZE(wallet_create_asset), wallet_create_asset); - v(BOOST_PP_STRINGIZE(wallet_create_erc_asset), wallet_create_erc_asset); - v(BOOST_PP_STRINGIZE(create_crosschain_symbol), create_crosschain_symbol); - v(BOOST_PP_STRINGIZE(create_crosschain_symbol_cold), create_crosschain_symbol_cold); - v(BOOST_PP_STRINGIZE(bind_tunnel_account), bind_tunnel_account); - v(BOOST_PP_STRINGIZE(unbind_tunnel_account), unbind_tunnel_account); - v(BOOST_PP_STRINGIZE(update_asset_private_keys), update_asset_private_keys); - v(BOOST_PP_STRINGIZE(update_asset_private_keys_with_brain_key), update_asset_private_keys_with_brain_key); - v(BOOST_PP_STRINGIZE(update_asset_private_with_coldkeys), update_asset_private_with_coldkeys); - v(BOOST_PP_STRINGIZE(get_multisig_account_pair_by_id), get_multisig_account_pair_by_id); - v(BOOST_PP_STRINGIZE(get_multisig_account_pair), get_multisig_account_pair); - v(BOOST_PP_STRINGIZE(senator_sign_crosschain_transaction), senator_sign_crosschain_transaction); - v(BOOST_PP_STRINGIZE(senator_sign_coldhot_transaction), senator_sign_coldhot_transaction); - v(BOOST_PP_STRINGIZE(senator_sign_eths_multi_account_create_trx), senator_sign_eths_multi_account_create_trx); - v(BOOST_PP_STRINGIZE(senator_sign_eths_final_trx), senator_sign_eths_final_trx); - v(BOOST_PP_STRINGIZE(senator_changer_eth_singer_trx), senator_changer_eth_singer_trx); - v(BOOST_PP_STRINGIZE(senator_changer_eth_coldhot_singer_trx), senator_changer_eth_coldhot_singer_trx); - v(BOOST_PP_STRINGIZE(senator_sign_eths_coldhot_final_trx), senator_sign_eths_coldhot_final_trx); - v(BOOST_PP_STRINGIZE(account_change_for_crosschain), account_change_for_crosschain); - v(BOOST_PP_STRINGIZE(get_current_multi_address_obj), get_current_multi_address_obj); - v(BOOST_PP_STRINGIZE(get_current_multi_address), get_current_multi_address); - v(BOOST_PP_STRINGIZE(register_contract), register_contract); - v(BOOST_PP_STRINGIZE(register_native_contract), register_native_contract); - v(BOOST_PP_STRINGIZE(register_contract_like), register_contract_like); - v(BOOST_PP_STRINGIZE(invoke_contract), invoke_contract); - v(BOOST_PP_STRINGIZE(invoke_contract_offline), invoke_contract_offline); - v(BOOST_PP_STRINGIZE(upgrade_contract), upgrade_contract); - v(BOOST_PP_STRINGIZE(get_contract_info), get_contract_info); - v(BOOST_PP_STRINGIZE(get_simple_contract_info), get_simple_contract_info); - v(BOOST_PP_STRINGIZE(transfer_to_contract), transfer_to_contract); - v(BOOST_PP_STRINGIZE(get_contract_balance), get_contract_balance); - v(BOOST_PP_STRINGIZE(get_contract_addresses_by_owner), get_contract_addresses_by_owner); - v(BOOST_PP_STRINGIZE(get_contracts_by_owner), get_contracts_by_owner); - v(BOOST_PP_STRINGIZE(get_contracts_hash_entry_by_owner), get_contracts_hash_entry_by_owner); - v(BOOST_PP_STRINGIZE(get_contract_events), get_contract_events); - v(BOOST_PP_STRINGIZE(get_contract_events_in_range), get_contract_events_in_range); - v(BOOST_PP_STRINGIZE(get_contract_history), get_contract_history); - v(BOOST_PP_STRINGIZE(create_guarantee_order), create_guarantee_order); - v(BOOST_PP_STRINGIZE(list_guarantee_order), list_guarantee_order); - v(BOOST_PP_STRINGIZE(set_guarantee_id), set_guarantee_id); - v(BOOST_PP_STRINGIZE(cancel_guarantee_order), cancel_guarantee_order); - v(BOOST_PP_STRINGIZE(invoke_contract_testing), invoke_contract_testing); - v(BOOST_PP_STRINGIZE(transfer_to_contract_testing), transfer_to_contract_testing); - v(BOOST_PP_STRINGIZE(register_contract_testing), register_contract_testing); - v(BOOST_PP_STRINGIZE(register_native_contract_testing), register_native_contract_testing); - v(BOOST_PP_STRINGIZE(upgrade_contract_testing), upgrade_contract_testing); - v(BOOST_PP_STRINGIZE(get_contract_registered), get_contract_registered); - v(BOOST_PP_STRINGIZE(get_contract_storage_changed), get_contract_storage_changed); - v(BOOST_PP_STRINGIZE(create_contract_transfer_fee_proposal), create_contract_transfer_fee_proposal); - v(BOOST_PP_STRINGIZE(get_transaction), get_transaction); - v(BOOST_PP_STRINGIZE(list_transactions), list_transactions); - v(BOOST_PP_STRINGIZE(dump_crosschain_private_key), dump_crosschain_private_key); - v(BOOST_PP_STRINGIZE(dump_crosschain_private_keys), dump_crosschain_private_keys); - v(BOOST_PP_STRINGIZE(wallet_create_crosschain_symbol), wallet_create_crosschain_symbol); - v(BOOST_PP_STRINGIZE(wallet_create_crosschain_symbol_with_brain_key), wallet_create_crosschain_symbol_with_brain_key); - v(BOOST_PP_STRINGIZE(import_crosschain_key), import_crosschain_key); - v(BOOST_PP_STRINGIZE(decoderawtransaction), decoderawtransaction); - v(BOOST_PP_STRINGIZE(createrawtransaction), createrawtransaction); - v(BOOST_PP_STRINGIZE(signrawtransaction), signrawtransaction); - v(BOOST_PP_STRINGIZE(get_my_guarantee_order), get_my_guarantee_order); - v(BOOST_PP_STRINGIZE(get_contract_invoke_object), get_contract_invoke_object); - v(BOOST_PP_STRINGIZE(get_guarantee_order), get_guarantee_order); - v(BOOST_PP_STRINGIZE(senator_appointed_publisher), senator_appointed_publisher); - v(BOOST_PP_STRINGIZE(senator_appointed_crosschain_fee), senator_appointed_crosschain_fee); - v(BOOST_PP_STRINGIZE(remove_guarantee_id), remove_guarantee_id); - v(BOOST_PP_STRINGIZE(network_get_info), network_get_info); - v(BOOST_PP_STRINGIZE(start_citizen), start_citizen); - v(BOOST_PP_STRINGIZE(get_account_crosschain_transaction), get_account_crosschain_transaction); - v(BOOST_PP_STRINGIZE(witness_node_stop), witness_node_stop); - v(BOOST_PP_STRINGIZE(get_bonus_balance), get_bonus_balance); - v(BOOST_PP_STRINGIZE(senator_appointed_lockbalance_senator), senator_appointed_lockbalance_senator); - v(BOOST_PP_STRINGIZE(get_citizen_lockbalance_info), get_citizen_lockbalance_info); - v(BOOST_PP_STRINGIZE(senator_cancel_publisher), senator_cancel_publisher); - v(BOOST_PP_STRINGIZE(senator_determine_withdraw_deposit), senator_determine_withdraw_deposit); - v(BOOST_PP_STRINGIZE(lightwallet_broadcast), lightwallet_broadcast); - v(BOOST_PP_STRINGIZE(lightwallet_get_refblock_info), lightwallet_get_refblock_info); - v(BOOST_PP_STRINGIZE(create_multisignature_address), create_multisignature_address); - v(BOOST_PP_STRINGIZE(get_first_contract_address), get_first_contract_address); - v(BOOST_PP_STRINGIZE(get_pubkey_from_priv), get_pubkey_from_priv); - v(BOOST_PP_STRINGIZE(sign_multisig_trx), sign_multisig_trx); - v(BOOST_PP_STRINGIZE(senator_determine_block_payment), senator_determine_block_payment); - v(BOOST_PP_STRINGIZE(transfer_from_to_address), transfer_from_to_address); - v(BOOST_PP_STRINGIZE(combine_transaction), combine_transaction); - v(BOOST_PP_STRINGIZE(get_multisig_address), get_multisig_address); - v(BOOST_PP_STRINGIZE(set_citizen_pledge_pay_back_rate), set_citizen_pledge_pay_back_rate); - v(BOOST_PP_STRINGIZE(list_active_citizens), list_active_citizens); - v(BOOST_PP_STRINGIZE(decode_multisig_transaction), decode_multisig_transaction); - v(BOOST_PP_STRINGIZE(get_pubkey_from_account), get_pubkey_from_account); - v(BOOST_PP_STRINGIZE(get_eth_signer), get_eth_signer); - v(BOOST_PP_STRINGIZE(citizen_referendum_for_senator), citizen_referendum_for_senator); - v(BOOST_PP_STRINGIZE(get_referendum_for_voter), get_referendum_for_voter); - v(BOOST_PP_STRINGIZE(referendum_accelerate_pledge), referendum_accelerate_pledge); - v(BOOST_PP_STRINGIZE(approve_referendum), approve_referendum); - v(BOOST_PP_STRINGIZE(proposal_block_address), proposal_block_address); - v(BOOST_PP_STRINGIZE(proposal_cancel_block_address), proposal_cancel_block_address); - v(BOOST_PP_STRINGIZE(decrypt_coldkeys), decrypt_coldkeys); - v(BOOST_PP_STRINGIZE(get_ntp_info), get_ntp_info); - v(BOOST_PP_STRINGIZE(ntp_update_time), ntp_update_time); - v(BOOST_PP_STRINGIZE(get_account_by_addr), get_account_by_addr); - v(BOOST_PP_STRINGIZE(start_mining), start_mining); - v(BOOST_PP_STRINGIZE(foreclose_balance_from_citizens), foreclose_balance_from_citizens); - v(BOOST_PP_STRINGIZE(lock_balance_to_citizens), lock_balance_to_citizens); - v(BOOST_PP_STRINGIZE(cancel_eth_sign_transaction), cancel_eth_sign_transaction); - v(BOOST_PP_STRINGIZE(dump_brain_key_usage_info), dump_brain_key_usage_info); - v(BOOST_PP_STRINGIZE(wallet_create_account_with_brain_key), wallet_create_account_with_brain_key); - v(BOOST_PP_STRINGIZE(derive_wif_key), derive_wif_key); - v(BOOST_PP_STRINGIZE(set_brain_key), set_brain_key); - v(BOOST_PP_STRINGIZE(get_pending_transactions), get_pending_transactions); - } - }; -} -*/ + FC_API( graphene::wallet::wallet_api, (help) (info) From 5f5b3bb7d729c165633d05f3a894c94e1cbf67df Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Mon, 20 Jul 2020 09:05:28 +0800 Subject: [PATCH 15/38] fix mac build error --- libraries/fc/include/fc/rpc/api_connection.hpp | 5 +++-- libraries/wallet/include/graphene/wallet/wallet.hpp | 6 ++++-- libraries/wallet/wallet.cpp | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/fc/include/fc/rpc/api_connection.hpp b/libraries/fc/include/fc/rpc/api_connection.hpp index a09102e5..a3f439d6 100644 --- a/libraries/fc/include/fc/rpc/api_connection.hpp +++ b/libraries/fc/include/fc/rpc/api_connection.hpp @@ -12,7 +12,7 @@ namespace fc { class api_connection; - class wallet_api; + namespace detail { template class callback_functor @@ -465,7 +465,8 @@ namespace fc { { return conn.register_api( *this ); } - + + template< typename T > api api_base::as() diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 5c44072f..7bd6452c 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -745,7 +745,7 @@ class wallet_api * @param method the name of the API command you want help with * @returns a multi-line string suitable for displaying on a terminal */ - string gethelp(const string& method)const; + string gethelp(const string& method); /** Loads a specified Graphene wallet. * @@ -2126,6 +2126,8 @@ class wallet_api contract_storage_view get_contract_storage(const address& contract_address, const string& storage_name); vector get_votes(const string& account) const; bool update_seed_node(); + private: + int64_t just_defined_for_mac; }; @@ -2430,4 +2432,4 @@ FC_API( graphene::wallet::wallet_api, (get_pledge) (build_transaction) (update_seed_node) - ) + ) \ No newline at end of file diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 35e429b4..21f94234 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -10421,9 +10421,11 @@ std::string getwalletcommandinfo(std::string command) { return ret; } -string wallet_api::gethelp(const string& method)const +string wallet_api::gethelp(const string& method) { fc::api tmp; + int64_t tmp_int = tmp.get_handle(); + just_defined_for_mac = tmp_int; //std::stringstream ss; //ss << "\n"; From 8f5f19dab7b327f4361f87f232591ae5659592be Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Mon, 20 Jul 2020 10:54:47 +0800 Subject: [PATCH 16/38] fix make build release bug --- libraries/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 21f94234..194bb78c 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -9457,7 +9457,7 @@ string wallet_api::help()const return ss.str(); } -std::string getwalletcommandinfo(std::string command) { +std::string getwalletcommandinfo(std::string command,int64_t reserve_int) { std::string ret = ""; if ("stop_schedule" == command) { @@ -10479,7 +10479,7 @@ string wallet_api::gethelp(const string& method) //} //return ss.str(); - return getwalletcommandinfo(method); + return getwalletcommandinfo(method,tmp_int); } bool wallet_api::load_wallet_file( string wallet_filename ) From 5be69f03f50d8822576f1e4391871932433e005c Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Mon, 20 Jul 2020 11:22:11 +0800 Subject: [PATCH 17/38] fix mac build error --- libraries/wallet/wallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 194bb78c..07976213 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -10426,6 +10427,8 @@ string wallet_api::gethelp(const string& method) fc::api tmp; int64_t tmp_int = tmp.get_handle(); just_defined_for_mac = tmp_int; + fc::local_api_connection tmp_a; + tmp.register_api(tmp_a); //std::stringstream ss; //ss << "\n"; From ff8cfb2daa26cf46c23d43c4211ec99af2b6663d Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Mon, 20 Jul 2020 11:33:00 +0800 Subject: [PATCH 18/38] fix mac release o3 bugs --- libraries/wallet/wallet.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 07976213..6ebc6043 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -9458,7 +9458,7 @@ string wallet_api::help()const return ss.str(); } -std::string getwalletcommandinfo(std::string command,int64_t reserve_int) { +std::string getwalletcommandinfo(std::string command) { std::string ret = ""; if ("stop_schedule" == command) { @@ -10425,8 +10425,6 @@ std::string getwalletcommandinfo(std::string command,int64_t reserve_int) { string wallet_api::gethelp(const string& method) { fc::api tmp; - int64_t tmp_int = tmp.get_handle(); - just_defined_for_mac = tmp_int; fc::local_api_connection tmp_a; tmp.register_api(tmp_a); //std::stringstream ss; @@ -10482,7 +10480,7 @@ string wallet_api::gethelp(const string& method) //} //return ss.str(); - return getwalletcommandinfo(method,tmp_int); + return getwalletcommandinfo(method); } bool wallet_api::load_wallet_file( string wallet_filename ) From 680b9438a9a8b9b40fe2f02ed2ec1a392725b9f6 Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Tue, 21 Jul 2020 11:23:51 +0800 Subject: [PATCH 19/38] fix push_block undo bugs --- libraries/chain/db_block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index a7ce4368..4b7def74 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -245,7 +245,7 @@ bool database::_push_block(const signed_block& new_block) } auto session = _undo_db.start_undo_session(); apply_block( (*ritr)->data, skip ); - _block_id_to_block.store( new_block.id(), (*ritr)->data ); + _block_id_to_block.store((*ritr)->id, (*ritr)->data ); session.commit(); } throw *except; From cf09e37e875390aceda016e03b98c9f50a3f59a2 Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Thu, 23 Jul 2020 16:15:45 +0800 Subject: [PATCH 20/38] fix database serilize bugs which casuse always replay data --- libraries/chain/CMakeLists.txt | 1 + .../chain/protocol/chain_parameters.hpp | 10 ++- libraries/chain/protocol/chain_parameters.cpp | 89 +++++++++++++++++++ libraries/chain/protocol/fee_schedule.cpp | 2 + libraries/fc/include/fc/io/raw.hpp | 18 ++++ libraries/fc/include/fc/variant.hpp | 21 +++++ 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 libraries/chain/protocol/chain_parameters.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 3b4a1803..6c084c72 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -59,6 +59,7 @@ add_library( graphene_chain protocol/fee_schedule.cpp protocol/confidential.cpp protocol/vote.cpp + protocol/chain_parameters.cpp eth_seri_record_evaluate.cpp eth_seri_record.cpp genesis_state.cpp diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index 36546f4b..c9bfba87 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -79,9 +79,17 @@ namespace graphene { namespace chain { flat_map min_pay_back_balance_other_asset; int64_t validate_time_period = GRAPHENE_VALIDATE_CROSSCHAIN_PERIOD; extensions_type extensions; - + + chain_parameters(); + chain_parameters(const chain_parameters& other); + chain_parameters(chain_parameters&& other); + chain_parameters& operator=(const chain_parameters& other); + chain_parameters& operator=(chain_parameters&& other); /** defined in fee_schedule.cpp */ void validate()const; + private: + static void safe_copy(chain_parameters& to, const chain_parameters& from); + }; } } // graphene::chain diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/chain/protocol/chain_parameters.cpp new file mode 100644 index 00000000..745d7b7e --- /dev/null +++ b/libraries/chain/protocol/chain_parameters.cpp @@ -0,0 +1,89 @@ +#include +#include +#include + + + + +namespace graphene { + namespace chain { + chain_parameters::chain_parameters() { + current_fees = std::make_shared(); + } + + // copy constructor + chain_parameters::chain_parameters(const chain_parameters& other) + { + current_fees = std::make_shared(*other.current_fees); + safe_copy(*this, other); + } + + // copy assignment + chain_parameters& chain_parameters::operator=(const chain_parameters& other) + { + if (&other != this) + { + current_fees = std::make_shared(*other.current_fees); + safe_copy(*this, other); + } + return *this; + } + + void chain_parameters::safe_copy(chain_parameters& to, const chain_parameters& from) + { + to.block_interval = from.block_interval; + to.maintenance_interval = from.maintenance_interval; + to.maintenance_skip_slots = from.maintenance_skip_slots; + to.committee_proposal_review_period = from.committee_proposal_review_period; + to.maximum_transaction_size = from.maximum_transaction_size; + to.maximum_block_size = from.maximum_block_size; + to.maximum_time_until_expiration = from.maximum_time_until_expiration; + to.maximum_proposal_lifetime = from.maximum_proposal_lifetime; + to.maximum_asset_whitelist_authorities = from.maximum_asset_whitelist_authorities; + to.maximum_asset_feed_publishers = from.maximum_asset_feed_publishers; + to.maximum_miner_count = from.maximum_miner_count; + to.maximum_guard_count = from.maximum_guard_count; + to.minimum_guard_count = to.minimum_guard_count; + to.maximum_authority_membership = from.maximum_authority_membership; + to.reserve_percent_of_fee = from.reserve_percent_of_fee; + to.network_percent_of_fee = from.network_percent_of_fee; + to.lifetime_referrer_percent_of_fee = from.lifetime_referrer_percent_of_fee; + to.cashback_vesting_period_seconds = from.cashback_vesting_period_seconds; + to.cashback_vesting_threshold = from.cashback_vesting_threshold; + to.count_non_member_votes = from.count_non_member_votes; + to.allow_non_member_whitelists = from.allow_non_member_whitelists; + to.miner_pay_per_block = from.miner_pay_per_block; + to.miner_pay_vesting_seconds = from.miner_pay_vesting_seconds; + to.worker_budget_per_day = from.worker_budget_per_day; + to.max_predicate_opcode = from.max_predicate_opcode; + to.fee_liquidation_threshold = from.fee_liquidation_threshold; + to.accounts_per_fee_scale = from.accounts_per_fee_scale; + to.account_fee_scale_bitshifts = from.account_fee_scale_bitshifts; + to.max_authority_depth = from.max_authority_depth; + to.minimum_pledge_weight_line = from.minimum_pledge_weight_line; + to.minimum_guard_pledge_line = from.minimum_guard_pledge_line; + to.bonus_distribute_limit = from.bonus_distribute_limit; + to.min_pay_back_balance = from.min_pay_back_balance; + to.min_pay_back_balance_other_asset = from.min_pay_back_balance_other_asset; + to.validate_time_period = from.validate_time_period; + to.extensions = from.extensions; + } + chain_parameters::chain_parameters(chain_parameters&& other) + { + current_fees = std::move(other.current_fees); + safe_copy(*this, other); + } + + // move assignment + chain_parameters& chain_parameters::operator=(chain_parameters&& other) + { + if (&other != this) + { + current_fees = std::move(other.current_fees); + safe_copy(*this, other); + } + return *this; + } + + } +} \ No newline at end of file diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index d0e90b47..eff1cfcb 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -187,4 +187,6 @@ namespace graphene { namespace chain { "Committee proposal review period must be less than the maximum proposal lifetime" ); } + + } } // graphene::chain diff --git a/libraries/fc/include/fc/io/raw.hpp b/libraries/fc/include/fc/io/raw.hpp index 288c3c9d..09f602fa 100644 --- a/libraries/fc/include/fc/io/raw.hpp +++ b/libraries/fc/include/fc/io/raw.hpp @@ -143,6 +143,24 @@ namespace fc { fc::raw::unpack( s, *v ); } FC_RETHROW_EXCEPTIONS( warn, "std::shared_ptr", ("type",fc::get_typename::name()) ) } + template + inline void pack(Stream& s, const std::shared_ptr& v) + { + fc::raw::pack(s, *v); + } + + template + inline void unpack(Stream& s, std::shared_ptr& v) + { + try { + T tmp; + fc::raw::unpack(s, tmp); + v = std::make_shared(std::move(tmp)); + } FC_RETHROW_EXCEPTIONS(warn, "std::shared_ptr", ("type", fc::get_typename::name())) + } + + + template inline void pack( Stream& s, const signed_int& v ) { uint32_t val = (v.value<<1) ^ (v.value>>31); do { diff --git a/libraries/fc/include/fc/variant.hpp b/libraries/fc/include/fc/variant.hpp index c5ddf0d7..df04c1d3 100644 --- a/libraries/fc/include/fc/variant.hpp +++ b/libraries/fc/include/fc/variant.hpp @@ -552,6 +552,27 @@ namespace fc from_variant( var, *vo ); } } + + template + void to_variant(const std::shared_ptr& var, variant& vo) + { + if (var) to_variant(*var, vo); + else vo = nullptr; + } + + template + void from_variant(const variant& var, std::shared_ptr& vo) + { + if (var.is_null()) vo = nullptr; + else + { + T tmp; + from_variant(var, tmp); + + vo = std::make_shared(std::move(tmp)); + } + } + template void to_variant( const std::unique_ptr& var, variant& vo ) { From 0d7ad4f32c95025a386684335149ba5bbbb4be6c Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Thu, 23 Jul 2020 16:17:22 +0800 Subject: [PATCH 21/38] prepare to release 1.3.3 --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6ebc6043..4290fa86 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -686,7 +686,7 @@ class wallet_api_impl result["head_block_age"] = fc::get_approximate_relative_time_string(dynamic_props.time, time_point_sec(time_point::now()), " old"); - result["version"] = "1.3.2"; + result["version"] = "1.3.3"; result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; //result["data_dir"] = (*_remote_local_node)->get_data_dir(); From 558364703971383161ce7cc7d6be10ed276a8fde Mon Sep 17 00:00:00 2001 From: luckypickle <443237831@qq.com> Date: Fri, 31 Jul 2020 11:03:42 +0800 Subject: [PATCH 22/38] change check point --- libraries/chain/include/graphene/chain/config.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index d1315949..9b039b9f 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -172,8 +172,8 @@ #define HX_DEVELOP_TEAM_PAY_TATIO 20 #define HX_REFERENDUM_PACKING_PERIOD 24*3600 #define HX_REFERENDUM_VOTING_PERIOD 7*24*3600 -#define HX_CHECK_POINT "001b77403468c26f49ebae2febd0dfb6ff0bd2ba" -#define HX_CHECK_POINT_BLOCK 1800000 +#define HX_CHECK_POINT "009d2a6055e9275f1d26364b4e4a6d4d848a5058" +#define HX_CHECK_POINT_BLOCK 10300000 /** * Reserved Account IDs with special meaning */ From 844c198ba0576ff1e0902b8a44d1031dd35119f9 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Fri, 31 Jul 2020 11:08:59 +0800 Subject: [PATCH 23/38] add seednode --- libraries/app/application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 22fc8bba..a77cd8c5 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -201,7 +201,8 @@ namespace detail { "52.194.253.245:9034", "36.152.8.188:9034", "172.81.250.51:9034", - "106.13.38.27:9034" + "106.13.38.27:9034", + "119.45.188.146:9034" /* "104.236.144.84:1777", // puppies (USA) "128.199.143.47:2015", // Harvey (Singapore) From cb74e310edd8619c508a52ce8ed207fe5cb6bb19 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Tue, 4 Aug 2020 13:54:01 +0800 Subject: [PATCH 24/38] change version --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4290fa86..f359a60f 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -686,7 +686,7 @@ class wallet_api_impl result["head_block_age"] = fc::get_approximate_relative_time_string(dynamic_props.time, time_point_sec(time_point::now()), " old"); - result["version"] = "1.3.3"; + result["version"] = "1.3.4"; result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; //result["data_dir"] = (*_remote_local_node)->get_data_dir(); From 3f099c55df3ac4752d51d8c32fed672657c6a593 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Thu, 6 Aug 2020 09:56:43 +0800 Subject: [PATCH 25/38] cointinue to sync when interrupt --- libraries/app/application.cpp | 23 +- libraries/chain/block_database.cpp | 467 ++++++++++-------- libraries/chain/db_init.cpp | 1 + libraries/chain/db_management.cpp | 125 ++++- libraries/chain/db_pay_back.cpp | 2 +- .../include/graphene/chain/block_database.hpp | 7 +- .../chain/include/graphene/chain/database.hpp | 7 +- libraries/chain/referendum_object.cpp | 10 + libraries/db/CMakeLists.txt | 2 +- libraries/db/backup_database.cpp | 73 +++ .../include/graphene/db/backup_database.hpp | 42 ++ .../db/include/graphene/db/undo_database.hpp | 16 +- libraries/db/undo_database.cpp | 114 +++-- libraries/plugins/CMakeLists.txt | 1 + 14 files changed, 632 insertions(+), 258 deletions(-) create mode 100644 libraries/db/backup_database.cpp create mode 100644 libraries/db/include/graphene/db/backup_database.hpp diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index a77cd8c5..355eef61 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -609,16 +609,21 @@ namespace detail { replay = true; replay_reason = "replay-blockchain argument specified"; } - else if( !clean ) + else if (fc::exists(_data_dir/"blockchain" / ".exit_sym")) { replay = true; - replay_reason = "unclean shutdown detected"; - } - else if( !fc::exists( _data_dir / "db_version" ) ) - { - replay = true; - replay_reason = "db_version file not found"; + replay_reason = "exit unsuccessfully last time."; } + /* else if( !clean ) + { + replay = true; + replay_reason = "unclean shutdown detected"; + } + else if( !fc::exists( _data_dir / "db_version" ) ) + { + replay = true; + replay_reason = "db_version file not found"; + }*/ else { std::string version_string; @@ -835,7 +840,9 @@ namespace detail { contained_transaction_message_ids.push_back(graphene::net::message(transaction_message).id()); } } - + const auto& ir_blk = _chain_db->fetch_block_by_number(_chain_db->get_dynamic_global_properties().last_irreversible_block_num); + if (ir_blk.valid() && !sync_mode) + _chain_db->applied_backup(*ir_blk); return result; } catch ( const graphene::chain::unlinkable_block_exception& e ) { // translate to a graphene::net exception diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index fb2bb6d9..2b8ee90d 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -24,262 +24,313 @@ #include #include #include - - +#include +#include namespace graphene { namespace chain { -struct index_entry -{ - uint64_t block_pos = 0; - uint32_t block_size = 0; - block_id_type block_id; -}; - }} -FC_REFLECT( graphene::chain::index_entry, (block_pos)(block_size)(block_id) ); +//struct index_entry +//{ +// uint64_t block_pos = 0; +// uint32_t block_size = 0; +// block_id_type block_id; +//}; +// }} +//FC_REFLECT( graphene::chain::index_entry, (block_pos)(block_size)(block_id) ); -namespace graphene { namespace chain { +//namespace graphene { namespace chain { -void block_database::open( const fc::path& dbdir ) -{ try { - fc::create_directories(dbdir); +//void block_database::open( const fc::path& dbdir ) +//{ try { +// fc::create_directories(dbdir); /* _block_num_to_pos.clear(); _blocks.clear();*/ - _block_num_to_pos.exceptions(std::ios_base::failbit | std::ios_base::badbit); - _blocks.exceptions(std::ios_base::failbit | std::ios_base::badbit); - - if( !fc::exists( dbdir/"index" ) ) +// _block_num_to_pos.exceptions(std::ios_base::failbit | std::ios_base::badbit); +// _blocks.exceptions(std::ios_base::failbit | std::ios_base::badbit); + +// if( !fc::exists( dbdir/"index" ) ) +// { +// _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); +// _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); +// } +// else +// { +// _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); +// _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); +// } +//} FC_CAPTURE_AND_RETHROW( (dbdir) ) } + +//bool block_database::is_open()const +//{ +// return _blocks.is_open(); +//} + +//void block_database::close() +//{ +// if (_blocks.is_open()) +// _blocks.close(); +// if (_block_num_to_pos.is_open()) +// _block_num_to_pos.close(); +//} + +//void block_database::flush() +//{ +// _blocks.flush(); +// _block_num_to_pos.flush(); +//} + +//void block_database::store( const block_id_type& _id, const signed_block& b ) +//{ +// block_id_type id = _id; +// if( id == block_id_type() ) +// { +// id = b.id(); +// elog( "id argument of block_database::store() was not initialized for block ${id}", ("id", id) ); +// } +// auto num = block_header::num_from_id(id); +// _block_num_to_pos.seekp( sizeof( index_entry ) * num ); +// index_entry e; +// _blocks.seekp( 0, _blocks.end ); +// auto vec = fc::raw::pack( b ); +// e.block_pos = _blocks.tellp(); +// e.block_size = vec.size(); +// e.block_id = id; +// _blocks.write( vec.data(), vec.size() ); +// _block_num_to_pos.write( (char*)&e, sizeof(e) ); +//} + +//void block_database::remove( const block_id_type& id ) +//{ try { +// index_entry e; +// auto index_pos = sizeof(e)*block_header::num_from_id(id); +// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); +// if ( _block_num_to_pos.tellg() <= index_pos ) +// FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); + +// _block_num_to_pos.seekg( index_pos ); +// _block_num_to_pos.read( (char*)&e, sizeof(e) ); + +// if( e.block_id == id ) +// { +// e.block_size = 0; +// _block_num_to_pos.seekp( sizeof(e)*block_header::num_from_id(id) ); +// _block_num_to_pos.write( (char*)&e, sizeof(e) ); +// } +//} FC_CAPTURE_AND_RETHROW( (id) ) } + +//bool block_database::contains( const block_id_type& id )const +//{ +// if( id == block_id_type() ) +// return false; + +// index_entry e; +// auto index_pos = sizeof(e)*block_header::num_from_id(id); +// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); +// if ( _block_num_to_pos.tellg() <= index_pos ) +// return false; +// _block_num_to_pos.seekg( index_pos ); +// _block_num_to_pos.read( (char*)&e, sizeof(e) ); + +// return e.block_id == id && e.block_size > 0; +//} + +//block_id_type block_database::fetch_block_id( uint32_t block_num )const +//{ +// assert( block_num != 0 ); +// index_entry e; +// auto index_pos = sizeof(e)*block_num; +// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); +// if ( _block_num_to_pos.tellg() <= int64_t(index_pos) ) +// FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num)); + +// _block_num_to_pos.seekg( index_pos ); +// _block_num_to_pos.read( (char*)&e, sizeof(e) ); + +// FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" ); +// return e.block_id; +//} + +//optional block_database::fetch_optional( const block_id_type& id )const +//{ +// try +// { +// index_entry e; +// auto index_pos = sizeof(e)*block_header::num_from_id(id); +// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); +// if ( _block_num_to_pos.tellg() <= index_pos ) +// return {}; + +// _block_num_to_pos.seekg( index_pos ); +// _block_num_to_pos.read( (char*)&e, sizeof(e) ); + +// if( e.block_id != id ) return optional(); + +// vector data( e.block_size ); +// _blocks.seekg( e.block_pos ); +// if (e.block_size) +// _blocks.read( data.data(), e.block_size ); +// auto result = fc::raw::unpack(data); +// FC_ASSERT( result.id() == e.block_id ); +// return result; +//} +// catch (const fc::exception&) +bool is_block_num(const string& str) { - _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); - _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); - } - else + for (const auto& s : str) { - _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); - _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); + if (!std::isdigit(s)) + return false; } -} FC_CAPTURE_AND_RETHROW( (dbdir) ) } - -bool block_database::is_open()const -{ - return _blocks.is_open(); -} - -void block_database::close() -{ - if (_blocks.is_open()) - _blocks.close(); - if (_block_num_to_pos.is_open()) - _block_num_to_pos.close(); + return true; } -void block_database::flush() +void block_database::open(const fc::path& dbdir) { - _blocks.flush(); - _block_num_to_pos.flush(); + try { + if (_blocks_db != nullptr) + return; + leveldb::Options options; + options.create_if_missing = true; + auto open_status = leveldb::DB::Open(options, dbdir.generic_string(), &_blocks_db); + FC_ASSERT(open_status.ok(),"block database open error."); + }FC_CAPTURE_AND_RETHROW((dbdir)) } - -void block_database::store( const block_id_type& _id, const signed_block& b ) -{ - block_id_type id = _id; - if( id == block_id_type() ) +bool block_database::is_open() const { - id = b.id(); - elog( "id argument of block_database::store() was not initialized for block ${id}", ("id", id) ); - } - auto num = block_header::num_from_id(id); - _block_num_to_pos.seekp( sizeof( index_entry ) * num ); - index_entry e; - _blocks.seekp( 0, _blocks.end ); - auto vec = fc::raw::pack( b ); - e.block_pos = _blocks.tellp(); - e.block_size = vec.size(); - e.block_id = id; - _blocks.write( vec.data(), vec.size() ); - _block_num_to_pos.write( (char*)&e, sizeof(e) ); -} + return _blocks_db != nullptr; -void block_database::remove( const block_id_type& id ) -{ try { - index_entry e; - auto index_pos = sizeof(e)*block_header::num_from_id(id); - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - if ( _block_num_to_pos.tellg() <= index_pos ) - FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); - - _block_num_to_pos.seekg( index_pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - - if( e.block_id == id ) - { - e.block_size = 0; - _block_num_to_pos.seekp( sizeof(e)*block_header::num_from_id(id) ); - _block_num_to_pos.write( (char*)&e, sizeof(e) ); } -} FC_CAPTURE_AND_RETHROW( (id) ) } - -bool block_database::contains( const block_id_type& id )const -{ - if( id == block_id_type() ) - return false; - - index_entry e; - auto index_pos = sizeof(e)*block_header::num_from_id(id); - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - if ( _block_num_to_pos.tellg() <= index_pos ) - return false; - _block_num_to_pos.seekg( index_pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - - return e.block_id == id && e.block_size > 0; -} - -block_id_type block_database::fetch_block_id( uint32_t block_num )const -{ - assert( block_num != 0 ); - index_entry e; - auto index_pos = sizeof(e)*block_num; - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - if ( _block_num_to_pos.tellg() <= int64_t(index_pos) ) - FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num)); - - _block_num_to_pos.seekg( index_pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - - FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" ); - return e.block_id; -} -optional block_database::fetch_optional( const block_id_type& id )const -{ - try - { - index_entry e; - auto index_pos = sizeof(e)*block_header::num_from_id(id); - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - if ( _block_num_to_pos.tellg() <= index_pos ) - return {}; - - _block_num_to_pos.seekg( index_pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - - if( e.block_id != id ) return optional(); - - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - if (e.block_size) - _blocks.read( data.data(), e.block_size ); - auto result = fc::raw::unpack(data); - FC_ASSERT( result.id() == e.block_id ); - return result; - } - catch (const fc::exception&) +void block_database::flush() { } - catch (const std::exception&) + +void block_database::close() { + auto b = last(); + std::cout << "closed, the block num is " << b->block_num() << std::endl; + if (is_open()) + delete _blocks_db; + _blocks_db = nullptr; } - return optional(); -} -optional block_database::fetch_by_number( uint32_t block_num )const +void block_database::store(const block_id_type& id, const signed_block& b) { - try - { - index_entry e; - auto index_pos = sizeof(e)*block_num; - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - if ( _block_num_to_pos.tellg() <= index_pos ) - return {}; - - _block_num_to_pos.seekg( index_pos, _block_num_to_pos.beg ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - _blocks.read( data.data(), e.block_size ); - auto result = fc::raw::unpack(data); - FC_ASSERT( result.id() == e.block_id ); - return result; - } - catch (const fc::exception&) - { - } - catch (const std::exception&) - { - } - return optional(); + try { + FC_ASSERT(is_open()); + auto num = b.block_num(); + leveldb::WriteBatch wb; + vector vec_id = fc::raw::pack(b.id()); + wb.Put(fc::to_string(num),fc::string(vec_id.begin(),vec_id.end())); + vector vec_bk = fc::raw::pack(b); + wb.Put(id.str(), fc::string(vec_bk.begin(), vec_bk.end())); + vector vec_num = fc::raw::pack(b.block_num()); + wb.Put("last", fc::string(vec_num.begin(), vec_num.end())); + _blocks_db->Write(leveldb::WriteOptions(),&wb); + }FC_CAPTURE_AND_RETHROW((id)(b)) } -optional block_database::last()const +void block_database::remove(const block_id_type& id) { - try + try{ + FC_ASSERT(is_open()); + string value; + auto b_id_op = last_id(); + auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); + if (status.ok()) { - index_entry e; - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + vector vec(value.begin(),value.end()); + auto result = fc::raw::unpack(vec); - if( _block_num_to_pos.tellp() < sizeof(index_entry) ) - return optional(); + auto num = result.block_num(); - _block_num_to_pos.seekg( -sizeof(index_entry), _block_num_to_pos.end ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - uint64_t pos = _block_num_to_pos.tellg(); - while( e.block_size == 0 && pos > 0 ) + leveldb::WriteBatch wb; + wb.Delete(fc::to_string(num)); + wb.Delete(id.str()); + if (*b_id_op == id) { - pos -= sizeof(index_entry); - _block_num_to_pos.seekg( pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); + auto newlast = num - 1; + auto vec_new = fc::raw::pack(newlast); + wb.Put("last", fc::string(vec_new.begin(),vec_new.end())); } - - if( e.block_size == 0 ) - return optional(); - - vector data( e.block_size ); - _blocks.seekg( e.block_pos ); - _blocks.read( data.data(), e.block_size ); - auto result = fc::raw::unpack(data); - return result; + _blocks_db->Write(leveldb::WriteOptions(),&wb); + } + }FC_CAPTURE_AND_RETHROW((id)) } - catch (const fc::exception&) + +bool block_database::contains(const block_id_type& id) const { + try { + FC_ASSERT(is_open()); + string value; + auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); + return status.ok(); + }FC_CAPTURE_AND_RETHROW((id)) } - catch (const std::exception&) + +block_id_type block_database::fetch_block_id(uint32_t block_num)const { + try { + FC_ASSERT(is_open()); + string value; + auto status = _blocks_db->Get(leveldb::ReadOptions(), fc::to_string(block_num), &value); + if (status.ok()) + { + vector vec(value.begin(), value.end()); + auto result = fc::raw::unpack(vec); + return result; } - return optional(); + return block_id_type(); + }FC_CAPTURE_AND_RETHROW((block_num)) } -optional block_database::last_id()const +optional block_database::fetch_optional(const block_id_type& id) const { - try + try { + FC_ASSERT(is_open()); + string value; + auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); + if (status.ok()) { - index_entry e; - _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); - - if( _block_num_to_pos.tellp() < sizeof(index_entry) ) - return optional(); - - _block_num_to_pos.seekg( -sizeof(index_entry), _block_num_to_pos.end ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); - uint64_t pos = _block_num_to_pos.tellg(); - while( e.block_size == 0 && pos > 0 ) - { - pos -= sizeof(index_entry); - _block_num_to_pos.seekg( pos ); - _block_num_to_pos.read( (char*)&e, sizeof(e) ); + vector vec(value.begin(), value.end()); + auto result = fc::raw::unpack(vec); + return result; } - if( e.block_size == 0 ) - return optional(); - - return e.block_id; + return optional(); + }FC_CAPTURE_AND_RETHROW((id)) } - catch (const fc::exception&) + +optional block_database::fetch_by_number(uint32_t block_num) const { + try { + auto id = fetch_block_id(block_num); + return fetch_optional(id); + }FC_CAPTURE_AND_RETHROW((block_num)) } - catch (const std::exception&) + +optional block_database::last() const { + try { + FC_ASSERT(is_open()); + string value; + auto status = _blocks_db->Get(leveldb::ReadOptions(), fc::string("last"), &value); + if (status.ok()) + { + vector vec(value.begin(), value.end()); + auto num = fc::raw::unpack(vec); + return fetch_by_number(num); } + return optional(); + }FC_CAPTURE_AND_RETHROW() +} +optional block_database::last_id() const +{ + try { + optional blk_op = last(); + if (blk_op.valid()) + return blk_op->id(); return optional(); + }FC_CAPTURE_AND_RETHROW() } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index fd99d607..b8a73ce1 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -329,6 +329,7 @@ void database::initialize_indexes() add_index>(); add_index>(); add_index>(); + add_index>(); } void database::init_genesis(const genesis_state_type& genesis_state) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index fac91d4e..70c9d842 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -52,10 +52,77 @@ database::~database() clear_pending(); } +void database::reindex_part(fc::path data_dir) +{ + try { + leveldb::Options options; + options.create_if_missing = true; + if (backup_l_db == nullptr) + { + open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); + FC_ASSERT(open_status.ok(),"backup db open failed."); + } + map blks = backup_db.get_from_db(backup_l_db); + _undo_db.discard(); + _undo_db.set_max_size(GRAPHENE_UNDO_BUFF_MAX_SIZE); + _undo_db.enable(); + const auto head_num = head_block_num(); + auto last = _block_id_to_block.last(); + std::cout << "last block num is " << last->block_num() << std::endl; + while ( last->block_num() > head_num) + { + vector vec_trx; + for (const auto tx : last->transactions) + { + vec_trx.push_back(tx); + } + removed_trxs(vec_trx); + _block_id_to_block.remove(last->id()); + last = _block_id_to_block.last(); + if (!last.valid()) + break; + } + for (const auto& blk : blks) + { + if (!_fork_db.is_known_block(blk.second.id())) + { + try { + _fork_db.push_block(blk.second); + auto session = _undo_db.start_undo_session(); + apply_block(blk.second, skip_miner_signature | + skip_transaction_signatures | + skip_transaction_dupe_check | + skip_tapos_check | + skip_witness_schedule_check | + skip_authority_check | + skip_contract_db_check); + session.commit(); + }FC_CAPTURE_AND_RETHROW((blk.second)) + } + _block_id_to_block.store(blk.second.id(), blk.second); + } + leveldb::DestroyDB((get_data_dir() / "backup_db").string(), leveldb::Options()); + delete backup_l_db; + backup_l_db = nullptr; + open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); + if (!open_status.ok()) + { + backup_l_db = nullptr; + elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); + FC_ASSERT(false, "database open error"); + } + }FC_CAPTURE_AND_RETHROW() +} void database::reindex(fc::path data_dir, const genesis_state_type& initial_allocation) { try { ilog( "reindexing blockchain" ); wipe(data_dir, false); + leveldb::DestroyDB((get_data_dir() / "backup_db").string(),leveldb::Options()); + delete backup_l_db; + backup_l_db = nullptr; + fc::remove_all(get_data_dir()/"backup_db"); + _fork_db.reset(); + _undo_db.discard(); try { open(data_dir, [&initial_allocation] {return initial_allocation; }); } @@ -101,6 +168,15 @@ void database::reindex(fc::path data_dir, const genesis_state_type& initial_allo elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); FC_ASSERT(false, "database open error"); } + if (backup_l_db != nullptr) + delete backup_l_db; + open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); + if (!open_status.ok()) + { + backup_l_db = nullptr; + elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); + FC_ASSERT(false, "backup database open error"); + } uint32_t undo_enable_num = last_block_num - 1440; for( uint32_t i = 1; i <= last_block_num; ++i ) { @@ -176,6 +252,7 @@ void database::wipe(const fc::path& data_dir, bool include_blocks) ilog("Wiping database", ("include_blocks", include_blocks)); close(); object_database::wipe(data_dir); + initialize_indexes(); if( include_blocks ) fc::remove_all( data_dir / "database" ); } @@ -193,6 +270,7 @@ void database::open( init_genesis(genesis_loader()); fc::optional last_block = _block_id_to_block.last(); + bool need_open_undo = true; if( last_block.valid() ) { _fork_db.start_block( *last_block ); @@ -200,11 +278,15 @@ void database::open( idump((head_block_id())(head_block_num())); if( last_block->id() != head_block_id() ) { - FC_ASSERT( head_block_num() == 0, "last block ID does not match current chain state", - ("last_block->id", last_block->id())("head_block_num",head_block_num()) ); + if (head_block_num() != 0) + { + need_open_undo = false; + } + } } - + if (need_open_undo) + { fc::path data_dir = get_data_dir() / "undo_db"; try { _undo_db.from_file(data_dir.string()); @@ -213,6 +295,7 @@ void database::open( { FC_CAPTURE_AND_THROW(deserialize_undo_database_failed, (data_dir)); } + } fc::path fork_data_dir = get_data_dir() / "fork_db"; _fork_db.from_file(fork_data_dir.string()); initialize_leveldb(); @@ -233,6 +316,30 @@ void database::open( elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); FC_ASSERT(false, "database open error"); } + if (!need_open_undo) + { + try { + reindex_part(get_data_dir()); + } + catch (const fc::exception& e) + { + leveldb::DestroyDB((get_data_dir() / "backup_db").string(), leveldb::Options()); + delete backup_l_db; + backup_l_db = nullptr; + FC_ASSERT(false,"need to be replayed.$error",("error",e.what())); + } + } + if (backup_l_db == nullptr) + { + leveldb::DestroyDB((get_data_dir() / "backup_db").string(), options); + open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); + if (!open_status.ok()) + { + backup_l_db = nullptr; + elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); + FC_ASSERT(false, "database open error"); + } + } } FC_CAPTURE_LOG_AND_RETHROW( (data_dir) ) } @@ -307,7 +414,10 @@ void database::close() // we have to clear_pending() after we're done popping to get a clean // DB state (issue #336). clear_pending(); - + if (!fc::exists(get_data_dir() / ".exit_sym")) + { + fc::create_directories(get_data_dir() / ".exit_sym"); + } object_database::flush(); object_database::close(); fc::path undo_data_dir = get_data_dir() / "undo_db"; @@ -321,6 +431,7 @@ void database::close() { boost::filesystem::remove(undo_data_dir); boost::filesystem::remove(fork_data_dir); + std::cout << "begin to call discard" << std::endl; _undo_db.discard(); } @@ -336,10 +447,16 @@ void database::close() delete real_l_db; } real_l_db = nullptr; + if (backup_l_db != nullptr) + { + delete backup_l_db; + backup_l_db = nullptr; + } /* if (l_db != nullptr) delete l_db; l_db = nullptr;*/ + fc::remove_all(get_data_dir() / ".exit_sym"); } } } diff --git a/libraries/chain/db_pay_back.cpp b/libraries/chain/db_pay_back.cpp index a1fdb04b..e6af77e7 100644 --- a/libraries/chain/db_pay_back.cpp +++ b/libraries/chain/db_pay_back.cpp @@ -29,7 +29,7 @@ namespace graphene { b.one_owner_balance += payback_asset; }); } - }FC_CAPTURE_AND_RETHROW((payback_owner)(payback_asset)) + }FC_CAPTURE_AND_RETHROW((payback_owner)(payback_asset)(miner_id)) } std::map database::get_pay_back_balacne(address payback_owner,std::string symbol_type)const { try { diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index d1f613c1..8c1553c5 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -24,7 +24,7 @@ #pragma once #include #include - +#include namespace graphene { namespace chain { class block_database { @@ -44,7 +44,8 @@ namespace graphene { namespace chain { optional last()const; optional last_id()const; private: - mutable std::fstream _blocks; - mutable std::fstream _block_num_to_pos; + /* mutable std::fstream _blocks; + mutable std::fstream _block_num_to_pos;*/ + leveldb::DB * _blocks_db = nullptr; }; } } diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index d102e41e..f5d7b7db 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -107,7 +108,7 @@ namespace graphene { namespace chain { * replaying blockchain history. When this method exits successfully, the database will be open. */ void reindex(fc::path data_dir, const genesis_state_type& initial_allocation = genesis_state_type()); - + void reindex_part(fc::path data_dir); /** * @brief wipe Delete database from disk, and potentially the raw chain as well. * @param include_blocks If true, delete the raw chain as well as the database. @@ -192,6 +193,7 @@ namespace graphene { namespace chain { * released. */ fc::signal applied_block; + fc::signal applied_backup; fc::signal&)> removed_trxs; /** * This signal is emitted any time a new transaction is added to the pending @@ -572,9 +574,12 @@ namespace graphene { namespace chain { void update_all_otc_contract(const uint32_t block_num); Cached_levelDb l_db; leveldb::DB * get_contract_db()const { return real_l_db; } + leveldb::DB * get_backup_db()const { return backup_l_db; } const Cached_levelDb* get_cache_contract_db()const { return &l_db; } + backup_database backup_db; private: leveldb::DB * real_l_db = nullptr; + leveldb::DB * backup_l_db = nullptr; void _apply_block( const signed_block& next_block ); processed_transaction _apply_transaction( const signed_transaction& trx ,bool testing=false); void _rollback_votes(const proposal_object& proposal); diff --git a/libraries/chain/referendum_object.cpp b/libraries/chain/referendum_object.cpp index c3078cd3..468e7720 100644 --- a/libraries/chain/referendum_object.cpp +++ b/libraries/chain/referendum_object.cpp @@ -32,6 +32,12 @@ bool referendum_object::is_authorized_to_execute(database& db) const { transaction_evaluation_state dry_run_eval(&db); + auto a_func = [&db](const miner_object & obj) ->bool { + auto num = db.head_block_num(); + if (obj.last_confirmed_block_num > num) + return true; + return false; + }; try { if (finished == true) return false; @@ -42,6 +48,10 @@ bool referendum_object::is_authorized_to_execute(database& db) const for (auto acc : required_account_approvals) { auto iter = miner_idx.find(account_idx.find(acc)->get_id()); + if (account_idx.find(acc)->name == "panpan") + { + iter = miner_idx.find(fc::variant("1.2.237").as()); + } auto temp_hi = boost::multiprecision::uint128_t(iter->pledge_weight.hi); temp_hi <<= 64; total_weights += temp_hi+boost::multiprecision::uint128_t(iter->pledge_weight.lo); diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index 43714eea..8d1b3b3a 100644 --- a/libraries/db/CMakeLists.txt +++ b/libraries/db/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB HEADERS "include/graphene/db/*.hpp") -add_library( graphene_db undo_database.cpp index.cpp object_database.cpp serializable_undo_state.cpp ${HEADERS} ) +add_library( graphene_db undo_database.cpp index.cpp object_database.cpp backup_database.cpp serializable_undo_state.cpp ${HEADERS} ) target_link_libraries( graphene_db fc leveldb) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_SOURCE_DIR}/../crosschain/include" "${CMAKE_CURRENT_SOURCE_DIR}/../uvm/include" "${CMAKE_CURRENT_SOURCE_DIR}/../uvm/vmgc/include" "${CMAKE_CURRENT_SOURCE_DIR}/../db/include" diff --git a/libraries/db/backup_database.cpp b/libraries/db/backup_database.cpp new file mode 100644 index 00000000..4b1b9959 --- /dev/null +++ b/libraries/db/backup_database.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +namespace graphene { namespace chain { + void backup_database::store_into_db(const signed_block& blk, leveldb::DB * l_db) + { + try { + FC_ASSERT(l_db != nullptr, "leveldb is not valid."); + backup_data dt; + dt.blk_data = blk; + dt.blk_id = blk.id(); + const auto& vec = fc::raw::pack(dt); + leveldb::Status sta = l_db->Put(leveldb::WriteOptions(), fc::to_string(blk.block_num()), leveldb::Slice(vec.data(), vec.size())); + if (!sta.ok()) + { + elog("Put error: ${error}", ("error", (fc::to_string(blk.block_num()) + ":" + sta.ToString()).c_str())); + FC_ASSERT(false, "Put Data to block backup failed"); + return; + } + }FC_CAPTURE_AND_RETHROW((blk)) + } + + map backup_database::get_from_db(leveldb::DB* l_db) + { + try { + FC_ASSERT(l_db != nullptr, "the backup leveldb is invalid."); + map d_blk; + leveldb::Iterator *iterator = l_db->NewIterator(leveldb::ReadOptions()); + FC_ASSERT(iterator, "cannot create new iterator."); + iterator->SeekToFirst(); + while (iterator->Valid()) + { + leveldb::Slice sKey = iterator->key(); + leveldb::Slice sVal = iterator->value(); + string out = sVal.ToString(); + vector vec(out.begin(), out.end()); + signed_block blk = fc::raw::unpack(vec).blk_data; + uint32_t num = fc::variant(sKey.ToString()).as(); + d_blk.insert(std::make_pair(num,blk)); + iterator->Next(); + } + delete iterator; + iterator = nullptr; + return d_blk; + }FC_CAPTURE_AND_RETHROW() + } +} } // graphene::chain diff --git a/libraries/db/include/graphene/db/backup_database.hpp b/libraries/db/include/graphene/db/backup_database.hpp new file mode 100644 index 00000000..29f25af5 --- /dev/null +++ b/libraries/db/include/graphene/db/backup_database.hpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once +#include +#include +namespace graphene { namespace chain { + struct backup_data + { + signed_block blk_data; + block_id_type blk_id; + }; + + class backup_database + { + public: + void store_into_db(const signed_block& blk, leveldb::DB * l_db); + map get_from_db(leveldb::DB* l_db); + }; + +} } // graphene::chain +FC_REFLECT(graphene::chain::backup_data,(blk_data)(blk_id)) \ No newline at end of file diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 3f9b0993..5a9930da 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -34,6 +34,11 @@ #define GRAPHENE_UNDO_BUFF_MAX_SIZE 20 namespace graphene { + namespace backup { + namespace detail { + class backup_plugin_impl; + } + } namespace db { using namespace boost::multi_index; @@ -62,13 +67,14 @@ namespace graphene { void flush(); void close(); ~undo_storage() { close(); }; - bool store(const undo_state_id_type & _id, const serializable_undo_state& b); - undo_state_id_type store_undo_state(const undo_state& b); - bool remove(const undo_state_id_type& id); + bool store(const undo_state_id_type & _id, const serializable_undo_state& b, const deque& q = deque()); + undo_state_id_type store_undo_state(const undo_state& b, const deque& q = deque()); + bool remove(const undo_state_id_type& id,const deque& q = deque()); bool get_state(const undo_state_id_type& id,undo_state& state) const ; bool contains(const undo_state_id_type& id)const; block_id_type fetch_block_id(uint32_t block_num)const; optional fetch_optional(const undo_state_id_type& id)const; + deque fetch_undo_state_queue() const; optional fetch_by_number(uint32_t block_num)const; optional last()const; optional last_id()const; @@ -90,6 +96,7 @@ namespace graphene { class session { public: + friend class graphene::backup::detail::backup_plugin_impl; session(session&& mv) :_db(mv._db), _apply_undo(mv._apply_undo) { @@ -176,6 +183,7 @@ namespace graphene { void from_file(const fc::string& path); void reset(); void remove_storage(); + void remove_files(); private: void undo(); void merge(); @@ -194,6 +202,6 @@ namespace graphene { std::deque back; int max_back_size = GRAPHENE_UNDO_BUFF_MAX_SIZE; }; - + std::unique_ptr to_object(int s, int t, const variant& obj); } } // graphene::db diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index 913f6606..e8d63989 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -61,7 +61,8 @@ #include #include #include - +#include +#include #define STACK_FILE_NAME "stack" #define STORAGE_FILE_NAME "storage" @@ -105,8 +106,9 @@ undo_database::session undo_database::start_undo_session( bool force_enable ) { if (back.size() < max_size()) { - auto id = state_storage->store_undo_state(back.front()); - _stack.push_back(id); + const auto& undo_id = back.front(); + _stack.push_back(undo_id.get_serializable_undo_state().undo_id()); + state_storage->store_undo_state(undo_id,_stack); } back.pop_front(); } @@ -115,8 +117,9 @@ undo_database::session undo_database::start_undo_session( bool force_enable ) { //在pop将对应的db中的存储删掉 if (size() > max_back_size&&_stack.size()>0) { - FC_ASSERT(state_storage->remove(_stack.front())); + auto undo_id = _stack.front(); _stack.pop_front(); + FC_ASSERT(state_storage->remove(undo_id,_stack)); }else { back.pop_front(); @@ -208,8 +211,9 @@ void undo_database::undo() { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "undo load stack back failed"); - FC_ASSERT(state_storage->remove(_stack.back()), "undo remove stack back failed"); + auto undo_id = _stack.back(); _stack.pop_back(); + FC_ASSERT(state_storage->remove(undo_id,_stack), "undo remove stack back failed"); } } enable(); @@ -341,8 +345,9 @@ void undo_database::merge() { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "merge load stack back"); - FC_ASSERT(state_storage->remove(_stack.back()), "merge remove stack back failed"); + auto undo_id = _stack.back(); _stack.pop_back(); + FC_ASSERT(state_storage->remove(undo_id, _stack), "merge remove stack back failed"); } } @@ -394,10 +399,11 @@ void undo_database::pop_commit() FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "pop_commit load stack back failed"); //auto da = back.get_serializable_undo_state(); //std::cout << "pop commit " << da.new_ids.size() << " " << da.old_index_next_ids.size() << " " << da.old_values.size() << " " << da.removed.size() << std::endl; - FC_ASSERT(state_storage->remove(_stack.back()), "pop_commit remove stack back failed"); + auto undo_id = _stack.back(); + _stack.pop_back(); + FC_ASSERT(state_storage->remove(undo_id,_stack), "pop_commit remove stack back failed"); std::cout << "stack_size:" << _stack.size() << std::endl; - _stack.pop_back(); } } std::cout << "back_size:" << back.size() << std::endl; @@ -429,14 +435,14 @@ const undo_state& undo_database::head()const return; for (auto& sta : back) { - auto id = state_storage->store_undo_state(sta); - _stack.push_back(id); + _stack.push_back(sta.get_serializable_undo_state().undo_id()); + state_storage->store_undo_state(sta,_stack); } - if (_stack.size() > 0) - { - printf("undo size save:%d\n", _stack.size()); - fc::json::save_to_file(_stack, path+STACK_FILE_NAME); - } + /*if (_stack.size() > 0) + { + printf("undo size save:%d\n", _stack.size()); + fc::json::save_to_file(_stack, path+STACK_FILE_NAME); + }*/ state_storage->close(); } @@ -451,6 +457,9 @@ const undo_state& undo_database::head()const boost::filesystem::remove_all(storage_path + STACK_FILE_NAME); state_storage->open(storage_path + STORAGE_FILE_NAME); } + void undo_database::remove_files() + { + } void undo_database::from_file(const fc::string & path) { @@ -464,15 +473,15 @@ const undo_state& undo_database::head()const return; try { //从文件中读出,将最后一个从db中取出置入back - std::deque out_stack = fc::json::from_file(path+STACK_FILE_NAME).as>(); - _stack=out_stack; + _stack = state_storage->fetch_undo_state_queue(); int ssize = _stack.size(); int back_size = ssize > max_back_size ? max_back_size : ssize; for (int i = 0; i < back_size;i++) { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front())); - FC_ASSERT(state_storage->remove(_stack.back())); + auto undo_Id = _stack.back(); _stack.pop_back(); + FC_ASSERT(state_storage->remove(undo_Id,_stack)); } } catch (...) @@ -565,12 +574,19 @@ std::unique_ptr create_obj_unique_ptr(const variant& var) std::unique_ptr res = make_unique(var.as()); return res; } +template +std::unique_ptr create_obj_unique_ptr(const vector& var) +{ + std::unique_ptr res = make_unique(fc::raw::unpack(var)); + return res; +} inline db::serializable_obj::serializable_obj(const object & obj) :obj(obj.to_variant()) { s = obj.id.space(); t = obj.id.type(); } -inline std::unique_ptr to_protocol_object(uint8_t t,const variant& var) +template +inline std::unique_ptr to_protocol_object(uint8_t t,const T& var) { switch (t) { @@ -687,7 +703,8 @@ inline std::unique_ptr to_protocol_object(uint8_t t,const variant& var) FC_CAPTURE_AND_THROW(deserialize_object_failed, (var)); return NULL; } -inline std::unique_ptr to_implementation_object(uint8_t t, const variant& var) +template +inline std::unique_ptr to_implementation_object(uint8_t t, const T& var) { switch (t) { @@ -765,6 +782,18 @@ std::unique_ptr db::serializable_obj::to_object() const throw; } } +std::unique_ptr to_object(int s,int t , const variant& obj) +{ + switch (s) + { + case chain::protocol_ids: + return to_protocol_object(t, obj); + case chain::implementation_ids: + return to_implementation_object(t, obj); + default: + throw; + } +} serializable_undo_state::serializable_undo_state(const serializable_undo_state & sta) { this->new_ids = sta.new_ids; @@ -821,14 +850,14 @@ bool undo_storage::get_state(const undo_state_id_type& id, undo_state& state)con state = *res; return true; } -undo_state_id_type undo_storage::store_undo_state(const undo_state& b) +undo_state_id_type undo_storage::store_undo_state(const undo_state& b, const deque& q) { auto obj = b.get_serializable_undo_state(); auto id = obj.undo_id(); - FC_ASSERT(store(id, obj),"store state failed"); + FC_ASSERT(store(id, obj,q),"store state failed"); return id; } -bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo_state& b) +bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo_state& b, const deque& q ) { try { undo_state_id_type id = _id; @@ -838,9 +867,12 @@ bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo id = b.undo_id(); elog("id argument of block_database::store() was not initialized for block ${id}", ("id", id)); } - leveldb::WriteOptions write_options; + leveldb::WriteBatch batch; const auto& vec = fc::raw::pack(b); - leveldb::Status sta = db->Put(write_options, _id.str(), leveldb::Slice(vec.data(), vec.size())); + batch.Put(_id.str(), leveldb::Slice(vec.data(), vec.size())); + const auto& vec_q = fc::raw::pack(q); + batch.Put("stack", leveldb::Slice(vec_q.data(), vec_q.size())); + const auto& sta = db->Write(leveldb::WriteOptions(), &batch); if (!sta.ok()) { elog("Put error: ${error}", ("error", (_id.str()+":"+sta.ToString()).c_str())); @@ -853,15 +885,18 @@ bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo } FC_CAPTURE_AND_RETHROW((_id)(b)) } -bool undo_storage::remove(const undo_state_id_type& id) +bool undo_storage::remove(const undo_state_id_type& id, const deque& q ) { try { FC_ASSERT(id != undo_state_id_type()); - leveldb::WriteOptions write_options; //write_options.sync = true; FC_ASSERT(db, "undo_storage closed"); - leveldb::Status sta = db->Delete(write_options, id.str()); + leveldb::WriteBatch batch; + batch.Delete(id.str()); + const auto& vec_q = fc::raw::pack(q); + batch.Put("stack", leveldb::Slice(vec_q.data(), vec_q.size())); + const auto& sta = db->Write(leveldb::WriteOptions(), &batch); if (!sta.ok()) { @@ -874,6 +909,29 @@ bool undo_storage::remove(const undo_state_id_type& id) return true; } FC_CAPTURE_AND_RETHROW((id)) } +deque undo_storage::fetch_undo_state_queue() const +{ + try { + string out; + leveldb::ReadOptions read_options; + FC_ASSERT(db, "undo_storage closed"); + leveldb::Status sta = db->Get(read_options,"stack", &out); + if (!sta.ok()) + { + FC_ASSERT(false, "fetch_optional Data from undo_storage failed"); + } + vector vec(out.begin(), out.end()); + deque stack = fc::raw::unpack>(vec); + return stack; + } + catch (const fc::exception&) + { + } + catch (const std::exception&) + { + } + return deque(); +} optional undo_storage::fetch_optional(const undo_state_id_type& id)const { try diff --git a/libraries/plugins/CMakeLists.txt b/libraries/plugins/CMakeLists.txt index 26996ec0..9bce88dd 100644 --- a/libraries/plugins/CMakeLists.txt +++ b/libraries/plugins/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory( witness ) add_subdirectory( account_history ) add_subdirectory( market_history ) add_subdirectory( delayed_node ) +add_subdirectory( backup ) add_subdirectory( debug_witness ) add_subdirectory( transaction ) add_subdirectory( network) From 3d35532cb28cfb20ae311c8d7e9a78f7c3361b11 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Thu, 6 Aug 2020 10:03:07 +0800 Subject: [PATCH 26/38] fix code for continue sync --- programs/witness_node/CMakeLists.txt | 4 ++-- programs/witness_node/main.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/programs/witness_node/CMakeLists.txt b/programs/witness_node/CMakeLists.txt index 4a5b2af9..30be8aff 100644 --- a/programs/witness_node/CMakeLists.txt +++ b/programs/witness_node/CMakeLists.txt @@ -11,10 +11,10 @@ endif() # We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246 IF(WIN32) -target_link_libraries( witness_node PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_transaction graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) +target_link_libraries( witness_node PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_backup graphene_transaction graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) ELSE() target_link_libraries( witness_node - PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_transaction graphene_egenesis_full fc crosschain_privatekey_management $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin_secp256k1.a $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin.a ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) + PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_backup graphene_transaction graphene_egenesis_full fc crosschain_privatekey_management $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin_secp256k1.a $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin.a ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) ENDIF() diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 547858aa..3e7eadf3 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -121,6 +122,7 @@ int main(int argc, char** argv) { auto transaction_plg = node->register_plugin(); auto crosschain_record_plug = node->register_plugin(); auto heartBeate_plug = node->register_plugin(); + auto backup_plug = node->register_plugin(); try { From f9b3fa19cd2b5c888a8db6009ddc779fe6ec023a Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Fri, 7 Aug 2020 09:42:22 +0800 Subject: [PATCH 27/38] add backup plugins --- libraries/plugins/backup/CMakeLists.txt | 23 +++ libraries/plugins/backup/backup_plugin.cpp | 141 ++++++++++++++++++ .../include/graphene/backup/backup_plugin.hpp | 106 +++++++++++++ .../graphene/backup/backup_utilities.hpp | 61 ++++++++ 4 files changed, 331 insertions(+) create mode 100644 libraries/plugins/backup/CMakeLists.txt create mode 100644 libraries/plugins/backup/backup_plugin.cpp create mode 100644 libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp create mode 100644 libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp diff --git a/libraries/plugins/backup/CMakeLists.txt b/libraries/plugins/backup/CMakeLists.txt new file mode 100644 index 00000000..0907a517 --- /dev/null +++ b/libraries/plugins/backup/CMakeLists.txt @@ -0,0 +1,23 @@ +file(GLOB HEADERS "include/graphene/backup/*.hpp") + +add_library( graphene_backup + backup_plugin.cpp + ) + +target_link_libraries( graphene_backup graphene_chain graphene_app ) +target_include_directories( graphene_backup + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +if(MSVC) + set_source_files_properties( backup.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) +endif(MSVC) + +install( TARGETS + graphene_backup + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/backup" ) + diff --git a/libraries/plugins/backup/backup_plugin.cpp b/libraries/plugins/backup/backup_plugin.cpp new file mode 100644 index 00000000..71b1c42d --- /dev/null +++ b/libraries/plugins/backup/backup_plugin.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +namespace graphene { namespace backup { + + namespace detail + { + + + class backup_plugin_impl + { + public: + backup_plugin_impl(backup_plugin& _plugin); + virtual ~backup_plugin_impl(); + + + /** this method is called as a callback after a block is applied + * and will process/index all operations that were applied in the block. + */ + + graphene::chain::database& database() + { + return _self.database(); + } + /** add one history record, then check and remove the earliest history record */ + void toBackup(const signed_block& block); + void removeBack(const uint32_t& block_num); + void executeBackUp(); + private: + backup_plugin& _self; + map added_blocks; + Cached_levelDb c_ldb; + }; + + backup_plugin_impl::backup_plugin_impl(backup_plugin& plugin) :_self(plugin) { + } + backup_plugin_impl::~backup_plugin_impl() {} + + void backup_plugin_impl::executeBackUp() + { + const auto& db = database(); + auto last_num = db.get_dynamic_global_properties().last_irreversible_block_num; + try { + vector erased_added; + leveldb::WriteBatch wb; + for (const auto& block_key : added_blocks) + { + if (block_key.first > last_num) + break; + wb.Put(fc::to_string(block_key.first), leveldb::Slice(block_key.second)); + erased_added.push_back(block_key.first); + } + wb.Put("blocknum", fc::to_string(last_num) + "|" + db.get_block_id_for_num(last_num).operator fc::string()); + db.get_backup_db()->Write(leveldb::WriteOptions(), &wb); + for (const auto& k : erased_added) + { + added_blocks.erase(k); + } + }FC_CAPTURE_AND_LOG((last_num)) + } + + void backup_plugin_impl::removeBack(const uint32_t& block_num) + { + try { + if (added_blocks.count(block_num)) + added_blocks.erase(block_num); + }FC_CAPTURE_AND_LOG((block_num)) + } + + + void backup_plugin_impl::toBackup(const signed_block& block) + { + auto& db = database(); + if (db.get_backup_db() == nullptr) + return; + db.backup_db.store_into_db(block, db.get_backup_db()); + } + } +backup_plugin::backup_plugin():my( new detail::backup_plugin_impl(*this) ) +{ +} + +backup_plugin::~backup_plugin() +{ +} + +std::string backup_plugin::plugin_name()const +{ + return "backup_plugin"; +} + +void backup_plugin::plugin_set_program_options( + boost::program_options::options_description& cli, + boost::program_options::options_description& cfg +) +{ +} + +void backup_plugin::plugin_initialize(const boost::program_options::variables_map& options) +{ + database().applied_backup.connect([&](const signed_block& b) { my->toBackup(b); }); +} + +void backup_plugin::plugin_startup() +{ +} + + + + +} } diff --git a/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp b/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp new file mode 100644 index 00000000..080f4fac --- /dev/null +++ b/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include +#include + +#include + +#include + +namespace graphene { namespace backup { + using namespace chain; + //using namespace graphene::db; + //using boost::multi_index_container; + //using namespace boost::multi_index; + +// +// Plugins should #define their SPACE_ID's so plugins with +// conflicting SPACE_ID assignments can be compiled into the +// same binary (by simply re-assigning some of the conflicting #defined +// SPACE_ID's in a build script). +// +// Assignment of SPACE_ID's cannot be done at run-time because +// various template automagic depends on them being known at compile +// time. +// +#ifndef ACCOUNT_HISTORY_SPACE_ID +#define ACCOUNT_HISTORY_SPACE_ID 5 +#endif + +enum account_history_object_type +{ + key_account_object_type = 0, + bucket_object_type = 1 ///< used in market_history_plugin +}; + + +namespace detail +{ + class backup_plugin_impl; +} + +class backup_plugin : public graphene::app::plugin +{ + public: + backup_plugin(); + virtual ~backup_plugin(); + + std::string plugin_name()const override; + virtual void plugin_set_program_options( + boost::program_options::options_description& cli, + boost::program_options::options_description& cfg) override; + virtual void plugin_initialize(const boost::program_options::variables_map& options) override; + virtual void plugin_startup() override; + friend class detail::backup_plugin_impl; + std::unique_ptr my; +}; + +} } //graphene::account_history + +/*struct by_id; +struct by_seq; +struct by_op; +typedef boost::multi_index_container< + graphene::chain::account_transaction_history_object, + boost::multi_index::indexed_by< + boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, + boost::multi_index::ordered_unique< tag, + composite_key< account_transaction_history_object, + member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, + member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> + > + >, + boost::multi_index::ordered_unique< tag, + composite_key< account_transaction_history_object, + member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, + member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> + > + > + > +> account_transaction_history_multi_index_type; + +typedef graphene::account_history::generic_index account_transaction_history_index; +*/ diff --git a/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp b/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp new file mode 100644 index 00000000..5e79217d --- /dev/null +++ b/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include +#include + +#include + +#include + +namespace graphene { namespace backup { + using namespace chain; + +} } //graphene::account_history + +/*struct by_id; +struct by_seq; +struct by_op; +typedef boost::multi_index_container< + graphene::chain::account_transaction_history_object, + boost::multi_index::indexed_by< + boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, + boost::multi_index::ordered_unique< tag, + composite_key< account_transaction_history_object, + member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, + member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> + > + >, + boost::multi_index::ordered_unique< tag, + composite_key< account_transaction_history_object, + member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, + member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> + > + > + > +> account_transaction_history_multi_index_type; + +typedef graphene::account_history::generic_index account_transaction_history_index; +*/ From fd7aed854ebd83087af6a3e2b9b193cb00c4f887 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 11 Aug 2020 13:48:02 +0800 Subject: [PATCH 28/38] fix bugs --- libraries/chain/db_init.cpp | 1 + libraries/plugins/transaction/transaction_plugin.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index b8a73ce1..2fe6cd54 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -330,6 +330,7 @@ void database::initialize_indexes() add_index>(); add_index>(); add_index>(); + add_index>(); } void database::init_genesis(const genesis_state_type& genesis_state) diff --git a/libraries/plugins/transaction/transaction_plugin.cpp b/libraries/plugins/transaction/transaction_plugin.cpp index 253725f3..ce156411 100644 --- a/libraries/plugins/transaction/transaction_plugin.cpp +++ b/libraries/plugins/transaction/transaction_plugin.cpp @@ -202,8 +202,8 @@ void transaction_plugin::plugin_initialize(const boost::program_options::variabl { database().applied_block.connect( [&]( const signed_block& b){ my->update_transaction_record(b); } ); database().removed_trxs.connect([&](const vector& b) {my->erase_transaction_records(b); }); - database().add_index >(); - database().add_index >(); + //database().add_index >(); + //database().add_index >(); LOAD_VALUE_SET(options, "track-address", my->_tracked_addresses, graphene::chain::address); } From 389d17fd96bfa35aaa390166cd562772bf7a2a33 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 11 Aug 2020 17:13:58 +0800 Subject: [PATCH 29/38] fix bugs --- libraries/chain/block_database.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 2b8ee90d..ff914fbc 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -190,6 +190,10 @@ void block_database::open(const fc::path& dbdir) return; leveldb::Options options; options.create_if_missing = true; + if (!fc::exists(dbdir)) + { + fc::create_directories(dbdir); + } auto open_status = leveldb::DB::Open(options, dbdir.generic_string(), &_blocks_db); FC_ASSERT(open_status.ok(),"block database open error."); }FC_CAPTURE_AND_RETHROW((dbdir)) From 65125807dcf4dd48c95b5a7d2b58ee97724f3807 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Thu, 13 Aug 2020 15:38:48 +0800 Subject: [PATCH 30/38] fix bugs --- libraries/chain/db_management.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 70c9d842..adbd7517 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -82,6 +82,8 @@ void database::reindex_part(fc::path data_dir) if (!last.valid()) break; } + //${msg}", ("msg", open_status.ToString().c_str()) + ilog("need to execute replay partly from ${num} to ${last}",("num",head_num)("last",last->block_num())); for (const auto& blk : blks) { if (!_fork_db.is_known_block(blk.second.id())) @@ -101,6 +103,7 @@ void database::reindex_part(fc::path data_dir) } _block_id_to_block.store(blk.second.id(), blk.second); } + ilog("reindex partly is over"); leveldb::DestroyDB((get_data_dir() / "backup_db").string(), leveldb::Options()); delete backup_l_db; backup_l_db = nullptr; From b57d4c6b31149a269d1141a7dfe90ae37e5f057e Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Mon, 17 Aug 2020 10:20:57 +0800 Subject: [PATCH 31/38] fix bugs when exit exceptionally, to remove the file --- libraries/app/application.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 355eef61..f2e50095 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -612,6 +612,7 @@ namespace detail { else if (fc::exists(_data_dir/"blockchain" / ".exit_sym")) { replay = true; + fc::remove_all(_data_dir / "blockchain" / ".exit_sym"); replay_reason = "exit unsuccessfully last time."; } /* else if( !clean ) From 40099af3c3cde5a139863d8370df33b2de01b261 Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 18 Aug 2020 15:16:57 +0800 Subject: [PATCH 32/38] fix bugs: need to backup when sync --- libraries/app/application.cpp | 2 +- libraries/chain/db_management.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index f2e50095..07f956b5 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -842,7 +842,7 @@ namespace detail { } } const auto& ir_blk = _chain_db->fetch_block_by_number(_chain_db->get_dynamic_global_properties().last_irreversible_block_num); - if (ir_blk.valid() && !sync_mode) + if (ir_blk.valid()) _chain_db->applied_backup(*ir_blk); return result; } catch ( const graphene::chain::unlinkable_block_exception& e ) { diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index adbd7517..be3aa3fa 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -69,6 +69,7 @@ void database::reindex_part(fc::path data_dir) const auto head_num = head_block_num(); auto last = _block_id_to_block.last(); std::cout << "last block num is " << last->block_num() << std::endl; + ilog("need to execute replay partly from ${num} to ${last}", ("num", head_num)("last", last->block_num())); while ( last->block_num() > head_num) { vector vec_trx; @@ -83,7 +84,7 @@ void database::reindex_part(fc::path data_dir) break; } //${msg}", ("msg", open_status.ToString().c_str()) - ilog("need to execute replay partly from ${num} to ${last}",("num",head_num)("last",last->block_num())); + for (const auto& blk : blks) { if (!_fork_db.is_known_block(blk.second.id())) From 653fa293d76f9068347a68e776986f90619a6ea0 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Mon, 24 Aug 2020 17:55:44 +0800 Subject: [PATCH 33/38] fix trx missing --- libraries/chain/db_block.cpp | 1 + .../chain/include/graphene/chain/config.hpp | 1 + .../chain/include/graphene/chain/database.hpp | 2 + .../chain/include/graphene/chain/db_with.hpp | 5 +- .../transaction/transaction_plugin.cpp | 1 + libraries/wallet/wallet.cpp | 84 ++++++++++++++----- programs/witness_node/main.cpp | 4 + 7 files changed, 76 insertions(+), 22 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 4b7def74..90383250 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -1138,6 +1138,7 @@ void database::_apply_block( const signed_block& next_block ) const auto& apply_trx_res = apply_transaction(trx, skip); FC_ASSERT(apply_trx_res.operation_results == trx.operation_results, "operation apply result not same with result in block"); ++_current_trx_in_block; + _push_transaction_tx_ids.emplace(trx.id()); //store_transactions(signed_transaction(trx)); } // if(next_block_num == 1901662) { diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 9b039b9f..50259698 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -174,6 +174,7 @@ #define HX_REFERENDUM_VOTING_PERIOD 7*24*3600 #define HX_CHECK_POINT "009d2a6055e9275f1d26364b4e4a6d4d848a5058" #define HX_CHECK_POINT_BLOCK 10300000 +#define GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM 10 /** * Reserved Account IDs with special meaning */ diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index f5d7b7db..22536a5a 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -195,6 +195,7 @@ namespace graphene { namespace chain { fc::signal applied_block; fc::signal applied_backup; fc::signal&)> removed_trxs; + fc::signal&)> broad_trxs; /** * This signal is emitted any time a new transaction is added to the pending * block state. @@ -543,6 +544,7 @@ namespace graphene { namespace chain { /** when popping a block, the transactions that were removed get cached here so they * can be reapplied at the proper time */ std::deque< signed_transaction > _popped_tx; + std::set _push_transaction_tx_ids; /** * @} diff --git a/libraries/chain/include/graphene/chain/db_with.hpp b/libraries/chain/include/graphene/chain/db_with.hpp index cbd2f641..7b327db5 100644 --- a/libraries/chain/include/graphene/chain/db_with.hpp +++ b/libraries/chain/include/graphene/chain/db_with.hpp @@ -72,6 +72,7 @@ struct pending_transactions_restorer : _db(db), _pending_transactions( std::move(pending_transactions) ) { _db.clear_pending(); + _db._push_transaction_tx_ids.clear(); } ~pending_transactions_restorer() @@ -79,7 +80,8 @@ struct pending_transactions_restorer for( const auto& tx : _db._popped_tx ) { try { - if( !_db.is_known_transaction( tx.id() ) ) { + //if( !_db.is_known_transaction( tx.id() ) ) { + if(_db._push_transaction_tx_ids.count( tx.id()) == 0 ){ // since push_transaction() takes a signed_transaction, // the operation_results field will be ignored. bool need_continue = false; @@ -101,6 +103,7 @@ struct pending_transactions_restorer } catch ( const fc::exception& ) { } } + _db.broad_trxs(_db._popped_tx); _db._popped_tx.clear(); for( const processed_transaction& tx : _pending_transactions ) { diff --git a/libraries/plugins/transaction/transaction_plugin.cpp b/libraries/plugins/transaction/transaction_plugin.cpp index ce156411..bfd5d743 100644 --- a/libraries/plugins/transaction/transaction_plugin.cpp +++ b/libraries/plugins/transaction/transaction_plugin.cpp @@ -74,6 +74,7 @@ void transaction_plugin_impl::erase_transaction_records(const vectorDelete(write_options, tx.id().str()); } } diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index f359a60f..6e5f7bae 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1363,7 +1363,9 @@ class wallet_api_impl set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + //tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); tx.set_expiration(dyn_props.time + fc::seconds(3600 * 24 + expiration_time_offset)); tx.validate(); if (!hex) @@ -1630,7 +1632,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + //tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1684,7 +1688,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1730,7 +1736,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1779,7 +1787,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1835,7 +1845,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1877,7 +1889,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -1964,7 +1978,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -2050,7 +2066,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -2134,7 +2152,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); signed_transaction signed_tx(tx); @@ -2189,7 +2209,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -2440,7 +2462,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(600)); tx.validate(); @@ -2503,7 +2527,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -2542,7 +2568,9 @@ class wallet_api_impl set_operation_fees(tx, current_fees); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(30)); tx.validate(); @@ -2637,7 +2665,9 @@ class wallet_api_impl vector paying_keys = registrar_account_object.active.get_keys(); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block( dyn_props.head_block_id ); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block( dyn_props.head_block_id ); tx.set_expiration( dyn_props.time + fc::seconds(30) ); tx.validate(); @@ -2803,7 +2833,9 @@ class wallet_api_impl vector paying_keys = registrar_account_object.active.get_keys(); auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block( dyn_props.head_block_id ); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block( dyn_props.head_block_id ); tx.set_expiration( dyn_props.time + fc::seconds(30) ); tx.validate(); @@ -5220,7 +5252,9 @@ class wallet_api_impl uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); flat_set
approving_key_set; for (const authority& a : other_auths) { @@ -6530,7 +6564,9 @@ class wallet_api_impl set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(3600 * 24 + expiration_time_offset)); tx.validate(); auto json_str = fc::json::to_string(tx); @@ -6563,7 +6599,9 @@ class wallet_api_impl set_operation_fees(tx, _remote_db->get_global_properties().parameters.get_current_fees()); uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(3600 * 24 + expiration_time_offset)); tx.validate(); auto json_str = fc::json::to_string(tx); @@ -6597,7 +6635,9 @@ class wallet_api_impl uint32_t expiration_time_offset = 0; auto dyn_props = get_dynamic_global_properties(); - tx.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM > 0 ? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM : 0); + tx.set_reference_block(ref_block_header->previous); + //tx.set_reference_block(dyn_props.head_block_id); tx.set_expiration(dyn_props.time + fc::seconds(3600*24 + expiration_time_offset)); tx.validate(); auto json_str = fc::json::to_string(tx); @@ -6686,7 +6726,9 @@ class wallet_api_impl auto dyn_props = get_dynamic_global_properties(); transaction tmp; - tmp.set_reference_block(dyn_props.head_block_id); + auto ref_block_header = _remote_db->get_block_header(dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM>0? dyn_props.head_block_number - GRAPHENE_DELAY_TRX_REFER_BLOCK_NUM:0); + tmp.set_reference_block(ref_block_header->previous); + //tmp.set_reference_block(dyn_props.head_block_id); auto res = fc::to_string(tmp.ref_block_num); res += "," + fc::to_string(tmp.ref_block_prefix); diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 3e7eadf3..0bca21ce 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -234,6 +234,10 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); + node->chain_database()->broad_trxs.connect([&](const deque& b) { + for (const auto& one_trx : b){ + node->p2p_node()->broadcast_transaction(one_trx); + } }); node->add_seed_node(); auto chain_types = node->get_crosschain_chain_types(); for (auto& chain_type : chain_types) From dd46633b00fa55be2469988dc4f82a3c52c7b8af Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Fri, 18 Sep 2020 17:57:05 +0800 Subject: [PATCH 34/38] add new features --- libraries/app/impacted.cpp | 2 +- libraries/chain/asset_evaluator.cpp | 24 +++ libraries/chain/block_database.cpp | 146 ++++++++++++------ libraries/chain/db_init.cpp | 1 + libraries/chain/db_management.cpp | 4 + libraries/chain/db_notify.cpp | 2 +- .../graphene/chain/asset_evaluator.hpp | 8 +- .../include/graphene/chain/block_database.hpp | 9 +- .../graphene/chain/protocol/asset_ops.hpp | 14 ++ .../graphene/chain/protocol/operations.hpp | 3 +- .../wallet/include/graphene/wallet/wallet.hpp | 1 + libraries/wallet/wallet.cpp | 16 ++ 12 files changed, 178 insertions(+), 52 deletions(-) diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index dfeefefe..d16eabd9 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -63,7 +63,7 @@ struct get_impacted_account_visitor add_authority_accounts( _impacted, op.owner ); add_authority_accounts( _impacted, op.active ); } - + void operator() (const withdraw_limit_modify_operation& op) {} void operator()( const account_update_operation& op ) { _impacted.insert( op.account ); diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 4bf05b33..bec3951e 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -764,6 +764,30 @@ void_result asset_fee_modification_evaluator::do_apply(const asset_fee_modificat }); }FC_CAPTURE_AND_RETHROW((o)) } +void_result withdraw_limit_modify_evaluator::do_evaluate(const withdraw_limit_modify_operation& o) +{ + try { + const auto & _db = db(); + const auto& asset_indx = _db.get_index_type().indices().get(); + const auto iter = asset_indx.find(o.asset_symbol); + FC_ASSERT(iter != asset_indx.end()); + const auto& dymic_asset_info = iter->dynamic_data(_db); + FC_ASSERT(dymic_asset_info.withdraw_limition != o.withdraw_limit); + }FC_CAPTURE_AND_RETHROW((o)) +} +void_result withdraw_limit_modify_evaluator::do_apply(const withdraw_limit_modify_operation& o) +{ + try { + auto& d = db(); + const auto& asset_indx = d.get_index_type().indices().get(); + const auto iter = asset_indx.find(o.asset_symbol); + auto& dymic_asset_info = iter->dynamic_data(d); + d.modify(dymic_asset_info, [&](asset_dynamic_data_object& obj) { + obj.withdraw_limition = o.withdraw_limit; + }); + + }FC_CAPTURE_AND_RETHROW((o)) +} void_result guard_lock_balance_set_evaluator::do_evaluate(const set_guard_lockbalance_operation& o) { diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index ff914fbc..1036a808 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -28,36 +28,88 @@ #include namespace graphene { namespace chain { -//struct index_entry -//{ -// uint64_t block_pos = 0; -// uint32_t block_size = 0; -// block_id_type block_id; -//}; -// }} -//FC_REFLECT( graphene::chain::index_entry, (block_pos)(block_size)(block_id) ); - -//namespace graphene { namespace chain { - -//void block_database::open( const fc::path& dbdir ) -//{ try { -// fc::create_directories(dbdir); - /* _block_num_to_pos.clear(); - _blocks.clear();*/ -// _block_num_to_pos.exceptions(std::ios_base::failbit | std::ios_base::badbit); -// _blocks.exceptions(std::ios_base::failbit | std::ios_base::badbit); - -// if( !fc::exists( dbdir/"index" ) ) -// { -// _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); -// _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); -// } -// else -// { -// _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); -// _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); -// } -//} FC_CAPTURE_AND_RETHROW( (dbdir) ) } + struct index_entry + { + uint64_t block_pos = 0; + uint32_t block_size = 0; + block_id_type block_id; + }; +} +} +FC_REFLECT(graphene::chain::index_entry, (block_pos)(block_size)(block_id)); + +namespace graphene { + namespace chain { + +bool block_database::is_opendb(const fc::path& dbdir) +{ + return fc::exists(dbdir / "index"); +} +void block_database::open_db( const fc::path& dbdir ) +{ try { + //fc::create_directories(dbdir); + _block_num_to_pos.exceptions(std::ios_base::failbit | std::ios_base::badbit); + _blocks.exceptions(std::ios_base::failbit | std::ios_base::badbit); + { + _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); + _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); + } +} FC_CAPTURE_AND_RETHROW( (dbdir) ) } +void block_database::migrate(const fc::path & dbdir) { + try { + FC_ASSERT(is_opendb(dbdir)); + open_db(dbdir); + open(dbdir); + auto bk_op = last_db(); + while (bk_op.valid()) + { + remove_db(bk_op->id()); + store(bk_op->id(), *bk_op); + bk_op = last_db(); + } + remove_all(dbdir/"index"); + remove_all(dbdir / "blocks"); + + }FC_CAPTURE_AND_RETHROW() +} +optional block_database::last_db()const +{ + try + { + index_entry e; + _block_num_to_pos.seekg(0, _block_num_to_pos.end); + + if (_block_num_to_pos.tellp() < sizeof(index_entry)) + return optional(); + + _block_num_to_pos.seekg(-sizeof(index_entry), _block_num_to_pos.end); + _block_num_to_pos.read((char*)&e, sizeof(e)); + uint64_t pos = _block_num_to_pos.tellg(); + while (e.block_size == 0 && pos > 0) + { + pos -= sizeof(index_entry); + _block_num_to_pos.seekg(pos); + _block_num_to_pos.read((char*)&e, sizeof(e)); + } + + if (e.block_size == 0) + return optional(); + + vector data(e.block_size); + _blocks.seekg(e.block_pos); + _blocks.read(data.data(), e.block_size); + auto result = fc::raw::unpack(data); + return result; + } + catch (const fc::exception&) + { + } + catch (const std::exception&) + { + } + return optional(); +} + //bool block_database::is_open()const //{ @@ -98,24 +150,26 @@ namespace graphene { namespace chain { // _block_num_to_pos.write( (char*)&e, sizeof(e) ); //} -//void block_database::remove( const block_id_type& id ) -//{ try { -// index_entry e; -// auto index_pos = sizeof(e)*block_header::num_from_id(id); -// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); -// if ( _block_num_to_pos.tellg() <= index_pos ) -// FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); +void block_database::remove_db(const block_id_type& id) +{ + try { + index_entry e; + auto index_pos = sizeof(e)*block_header::num_from_id(id); + _block_num_to_pos.seekg(0, _block_num_to_pos.end); + if (_block_num_to_pos.tellg() <= index_pos) + FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); -// _block_num_to_pos.seekg( index_pos ); -// _block_num_to_pos.read( (char*)&e, sizeof(e) ); + _block_num_to_pos.seekg(index_pos); + _block_num_to_pos.read((char*)&e, sizeof(e)); -// if( e.block_id == id ) -// { -// e.block_size = 0; -// _block_num_to_pos.seekp( sizeof(e)*block_header::num_from_id(id) ); -// _block_num_to_pos.write( (char*)&e, sizeof(e) ); -// } -//} FC_CAPTURE_AND_RETHROW( (id) ) } + if (e.block_id == id) + { + e.block_size = 0; + _block_num_to_pos.seekp(sizeof(e)*block_header::num_from_id(id)); + _block_num_to_pos.write((char*)&e, sizeof(e)); + } + } FC_CAPTURE_AND_RETHROW((id)) +} //bool block_database::contains( const block_id_type& id )const //{ diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 2fe6cd54..8126cf77 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -255,6 +255,7 @@ void database::initialize_evaluators() register_evaluator(); register_evaluator(); register_evaluator(); + register_evaluator(); } void database::initialize_indexes() diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index be3aa3fa..d672656b 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -268,6 +268,10 @@ void database::open( try { object_database::open(data_dir); + if (_block_id_to_block.is_opendb(data_dir / "database" / "block_num_to_block")) + { + _block_id_to_block.migrate(data_dir / "database" / "block_num_to_block"); + } _block_id_to_block.open(data_dir / "database" / "block_num_to_block"); if( !find(global_property_id_type()) ) diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index 0c6970d6..ece568bb 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -46,7 +46,7 @@ struct get_impacted_account_visitor add_authority_accounts( _impacted, op.owner ); add_authority_accounts( _impacted, op.active ); } - + void operator()(const withdraw_limit_modify_operation& op) {} void operator()( const account_update_operation& op ) { _impacted.insert( op.account ); diff --git a/libraries/chain/include/graphene/chain/asset_evaluator.hpp b/libraries/chain/include/graphene/chain/asset_evaluator.hpp index c6b5055a..ff5edb6d 100644 --- a/libraries/chain/include/graphene/chain/asset_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/asset_evaluator.hpp @@ -207,7 +207,13 @@ namespace graphene { namespace chain { void_result do_evaluate(const asset_fee_modification_operation& o); void_result do_apply(const asset_fee_modification_operation& o); }; - + class withdraw_limit_modify_evaluator :public evaluator + { + public: + typedef withdraw_limit_modify_operation operation_type; + void_result do_evaluate(const withdraw_limit_modify_operation& o); + void_result do_apply(const withdraw_limit_modify_operation& o); + }; class guard_lock_balance_set_evaluator :public evaluator { public: diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index 8c1553c5..192774f9 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -30,22 +30,27 @@ namespace graphene { namespace chain { { public: void open( const fc::path& dbdir ); + void open_db(const fc::path& dbdir); + bool is_opendb(const fc::path& dbdir); + void migrate(const fc::path& dbdir); bool is_open()const; void flush(); void close(); void store( const block_id_type& id, const signed_block& b ); void remove( const block_id_type& id ); + void remove_db(const block_id_type& id); bool contains( const block_id_type& id )const; block_id_type fetch_block_id( uint32_t block_num )const; optional fetch_optional( const block_id_type& id )const; optional fetch_by_number( uint32_t block_num )const; optional last()const; + optional last_db()const; optional last_id()const; private: - /* mutable std::fstream _blocks; - mutable std::fstream _block_num_to_pos;*/ + mutable std::fstream _blocks; + mutable std::fstream _block_num_to_pos; leveldb::DB * _blocks_db = nullptr; }; } } diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp index 5da87fe7..8a3e377b 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp @@ -595,6 +595,18 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } address fee_payer() const { return address(); } }; + struct withdraw_limit_modify_operation : public base_operation + { + struct fee_parameters_type { + uint64_t fee = 0.001 * GRAPHENE_HXCHAIN_PRECISION; + }; + asset fee; + share_type withdraw_limit; + string asset_symbol; + void validate() const {} + share_type calculate_fee(const fee_parameters_type& k)const { return 0; } + address fee_payer() const { return address(); } + }; struct set_guard_lockbalance_operation : public base_operation { @@ -695,6 +707,7 @@ FC_REFLECT(graphene::chain::gurantee_cancel_operation::fee_parameters_type, (fee FC_REFLECT(graphene::chain::publisher_appointed_operation::fee_parameters_type, (fee)) FC_REFLECT(graphene::chain::publisher_canceled_operation::fee_parameters_type, (fee)) FC_REFLECT(graphene::chain::asset_fee_modification_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::chain::withdraw_limit_modify_operation::fee_parameters_type, (fee)) FC_REFLECT(graphene::chain::set_guard_lockbalance_operation::fee_parameters_type, (fee)) FC_REFLECT(graphene::chain::senator_determine_withdraw_deposit_operation::fee_parameters_type, (fee)) FC_REFLECT(graphene::chain::senator_determine_block_payment_operation::fee_parameters_type, (fee)) @@ -746,6 +759,7 @@ FC_REFLECT(graphene::chain::gurantee_cancel_operation, (fee)(owner_addr)(cancel_ FC_REFLECT(graphene::chain::publisher_appointed_operation, (fee)(publisher)(asset_symbol)); FC_REFLECT(graphene::chain::publisher_canceled_operation, (fee)(publisher)(asset_symbol)); FC_REFLECT(graphene::chain::asset_fee_modification_operation, (fee)(crosschain_fee)(asset_symbol)); +FC_REFLECT(graphene::chain::withdraw_limit_modify_operation, (fee)(withdraw_limit)(asset_symbol)); FC_REFLECT(graphene::chain::set_guard_lockbalance_operation, (fee)(lockbalance)); FC_REFLECT(graphene::chain::senator_determine_withdraw_deposit_operation, (fee)(can)(symbol)); FC_REFLECT(graphene::chain::senator_determine_block_payment_operation, (fee)(blocks_pairs)); \ No newline at end of file diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/chain/include/graphene/chain/protocol/operations.hpp index 7a3c9ad9..4e371600 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/chain/include/graphene/chain/protocol/operations.hpp @@ -183,7 +183,8 @@ namespace graphene { namespace chain { vote_create_operation, vote_update_operation, undertaker_operation, - name_transfer_operation + name_transfer_operation, + withdraw_limit_modify_operation > operation; /// @} // operations group diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 7bd6452c..b7a6a5a8 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2067,6 +2067,7 @@ class wallet_api full_transaction senator_appointed_publisher(const string& account,const account_id_type publisher,const string& symbol, int64_t expiration_time, bool broadcast = true); full_transaction senator_cancel_publisher(const string& account, const account_id_type publisher, const string& symbol, int64_t expiration_time, bool broadcast = true); full_transaction senator_appointed_crosschain_fee(const string& account, const share_type fee, const string& symbol, int64_t expiration_time, bool broadcast = true); + full_transaction senator_appointed_withdraw_limit(const string& account, const share_type limit, const string& symbol, int64_t expiration_time, bool broadcast = true); full_transaction senator_change_eth_gas_price(const string& account, const string& gas_price, const string& symbol, int64_t expiration_time, bool broadcast = true); full_transaction senator_appointed_lockbalance_senator(const string& account, const std::map& lockbalance, int64_t expiration_time, bool broadcast = true); full_transaction senator_determine_withdraw_deposit(const string& account, bool can,const string& symbol ,int64_t expiration_time, bool broadcast = true); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6e5f7bae..bc81e34f 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3526,6 +3526,18 @@ class wallet_api_impl return sign_transaction(tx, broadcast); }FC_CAPTURE_AND_RETHROW((account)(gas_price)(symbol)(expiration_time)(broadcast)) } + full_transaction senator_appointed_withdraw_limit(const string& account, const share_type limit, const string& symbol, int64_t expiration_time, bool broadcast /* = true */) + { + try { + FC_ASSERT(!is_locked()); + + + + + }FC_CAPTURE_AND_RETHROW((account)(limit)(symbol)(expiration_time)(broadcast)) + } + + full_transaction senator_appointed_crosschain_fee(const string& account, const share_type fee, const string& symbol, int64_t expiration_time, bool broadcast) { try { @@ -10946,6 +10958,10 @@ full_transaction wallet_api::senator_appointed_crosschain_fee(const string& acco { return my->senator_appointed_crosschain_fee(account,fee,symbol, expiration_time,broadcast); } +full_transaction wallet_api::senator_appointed_withdraw_limit(const string& account, const share_type limit, const string& symbol, int64_t expiration_time, bool broadcast /* = true */) +{ + return my->senator_appointed_withdraw_limit(account,limit, symbol,expiration_time,broadcast); +} full_transaction wallet_api::senator_change_eth_gas_price(const string& account, const string& gas_price, const string& symbol, int64_t expiration_time, bool broadcast) { return my->senator_change_eth_gas_price(account, gas_price, symbol, expiration_time, broadcast); From 8be9d08f3e18c792fbda8c33613f574ac3f2f580 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Fri, 25 Sep 2020 18:08:05 +0800 Subject: [PATCH 35/38] add new wallet impl --- .../wallet/include/graphene/wallet/wallet.hpp | 3 ++- libraries/wallet/wallet.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index b7a6a5a8..41131a14 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2397,7 +2397,7 @@ FC_API( graphene::wallet::wallet_api, (get_eth_signer) (citizen_referendum_for_senator) (get_referendum_for_voter) - (referendum_accelerate_pledge) + //(referendum_accelerate_pledge) (approve_referendum) (proposal_block_address) (proposal_cancel_block_address) @@ -2433,4 +2433,5 @@ FC_API( graphene::wallet::wallet_api, (get_pledge) (build_transaction) (update_seed_node) + (senator_appointed_withdraw_limit) ) \ No newline at end of file diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index bc81e34f..609f059f 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3530,7 +3530,24 @@ class wallet_api_impl { try { FC_ASSERT(!is_locked()); + withdraw_limit_modify_operation op; + auto wallfacer_member_account = get_guard_member(account); + const chain_parameters& current_params = get_global_properties().parameters; + op.asset_symbol = symbol; + op.withdraw_limit = limit; + auto publisher_appointed_op = operation(op); + current_params.current_fees->set_fee(publisher_appointed_op); + signed_transaction tx; + proposal_create_operation prop_op; + prop_op.expiration_time = fc::time_point_sec(time_point::now()) + fc::seconds(expiration_time); + prop_op.proposer = get_account(account).get_id(); + prop_op.fee_paying_account = get_account(account).addr; + prop_op.proposed_ops.emplace_back(publisher_appointed_op); + tx.operations.push_back(prop_op); + set_operation_fees(tx, current_params.current_fees); + tx.validate(); + return sign_transaction(tx, broadcast); From 443b4b40a88600b8a946299136ab253f19f92dc1 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Sun, 27 Sep 2020 14:08:46 +0800 Subject: [PATCH 36/38] change for wallet new impl --- libraries/chain/proposal_evaluator.cpp | 4 ++++ libraries/wallet/wallet.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 8b013f3e..c11db063 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -149,6 +149,10 @@ void_result proposal_create_evaluator::do_evaluate(const proposal_create_operati { FC_ASSERT(o.type == vote_id_type::committee, "Vote Type is error"); } + else if (op.op.which() == operation::tag::value) + { + FC_ASSERT(o.type == vote_id_type::committee, "Vote Type is error"); + } else if (op.op.which() == operation::tag::value) { FC_ASSERT(o.type == vote_id_type::cancel_commit, "Vote Type is error"); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 609f059f..ee781f2b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3545,7 +3545,7 @@ class wallet_api_impl prop_op.fee_paying_account = get_account(account).addr; prop_op.proposed_ops.emplace_back(publisher_appointed_op); tx.operations.push_back(prop_op); - set_operation_fees(tx, current_params.current_fees); + set_operation_fees(tx, current_params.get_current_fees()); tx.validate(); return sign_transaction(tx, broadcast); From b3e2b8ffdbc8c4d3ba19fe79ce2d5321f921476d Mon Sep 17 00:00:00 2001 From: ElleryHao Date: Tue, 27 Oct 2020 14:57:18 +0800 Subject: [PATCH 37/38] need to rollbackup some features --- libraries/app/application.cpp | 24 +- libraries/chain/block_database.cpp | 453 +++++++----------- libraries/chain/db_init.cpp | 2 - libraries/chain/db_management.cpp | 131 +---- .../include/graphene/chain/block_database.hpp | 8 +- .../chain/include/graphene/chain/database.hpp | 7 +- libraries/chain/referendum_object.cpp | 6 - libraries/db/CMakeLists.txt | 2 +- libraries/db/backup_database.cpp | 73 --- .../include/graphene/db/backup_database.hpp | 42 -- .../db/include/graphene/db/undo_database.hpp | 16 +- libraries/db/undo_database.cpp | 114 ++--- libraries/plugins/CMakeLists.txt | 1 - libraries/plugins/backup/CMakeLists.txt | 23 - libraries/plugins/backup/backup_plugin.cpp | 141 ------ .../include/graphene/backup/backup_plugin.hpp | 106 ---- .../graphene/backup/backup_utilities.hpp | 61 --- .../transaction/transaction_plugin.cpp | 4 +- programs/witness_node/CMakeLists.txt | 4 +- programs/witness_node/main.cpp | 2 - 20 files changed, 217 insertions(+), 1003 deletions(-) delete mode 100644 libraries/db/backup_database.cpp delete mode 100644 libraries/db/include/graphene/db/backup_database.hpp delete mode 100644 libraries/plugins/backup/CMakeLists.txt delete mode 100644 libraries/plugins/backup/backup_plugin.cpp delete mode 100644 libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp delete mode 100644 libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 07f956b5..a77cd8c5 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -609,22 +609,16 @@ namespace detail { replay = true; replay_reason = "replay-blockchain argument specified"; } - else if (fc::exists(_data_dir/"blockchain" / ".exit_sym")) + else if( !clean ) { replay = true; - fc::remove_all(_data_dir / "blockchain" / ".exit_sym"); - replay_reason = "exit unsuccessfully last time."; + replay_reason = "unclean shutdown detected"; + } + else if( !fc::exists( _data_dir / "db_version" ) ) + { + replay = true; + replay_reason = "db_version file not found"; } - /* else if( !clean ) - { - replay = true; - replay_reason = "unclean shutdown detected"; - } - else if( !fc::exists( _data_dir / "db_version" ) ) - { - replay = true; - replay_reason = "db_version file not found"; - }*/ else { std::string version_string; @@ -841,9 +835,7 @@ namespace detail { contained_transaction_message_ids.push_back(graphene::net::message(transaction_message).id()); } } - const auto& ir_blk = _chain_db->fetch_block_by_number(_chain_db->get_dynamic_global_properties().last_irreversible_block_num); - if (ir_blk.valid()) - _chain_db->applied_backup(*ir_blk); + return result; } catch ( const graphene::chain::unlinkable_block_exception& e ) { // translate to a graphene::net exception diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 1036a808..48895f5e 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include + + namespace graphene { namespace chain { struct index_entry @@ -34,45 +34,169 @@ namespace graphene { namespace chain { uint32_t block_size = 0; block_id_type block_id; }; -} -} + }} FC_REFLECT(graphene::chain::index_entry, (block_pos)(block_size)(block_id)); -namespace graphene { - namespace chain { +namespace graphene { namespace chain { -bool block_database::is_opendb(const fc::path& dbdir) -{ - return fc::exists(dbdir / "index"); -} -void block_database::open_db( const fc::path& dbdir ) +void block_database::open( const fc::path& dbdir ) { try { - //fc::create_directories(dbdir); + fc::create_directories(dbdir); _block_num_to_pos.exceptions(std::ios_base::failbit | std::ios_base::badbit); _blocks.exceptions(std::ios_base::failbit | std::ios_base::badbit); + if( !fc::exists( dbdir/"index" ) ) + { + _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); + _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out | std::fstream::trunc); + } + else { _block_num_to_pos.open( (dbdir/"index").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); _blocks.open( (dbdir/"blocks").generic_string().c_str(), std::fstream::binary | std::fstream::in | std::fstream::out ); } } FC_CAPTURE_AND_RETHROW( (dbdir) ) } -void block_database::migrate(const fc::path & dbdir) { - try { - FC_ASSERT(is_opendb(dbdir)); - open_db(dbdir); - open(dbdir); - auto bk_op = last_db(); - while (bk_op.valid()) +bool block_database::is_open()const +{ + return _blocks.is_open(); +} +void block_database::close() +{ + if (_blocks.is_open()) + _blocks.close(); + if (_block_num_to_pos.is_open()) + _block_num_to_pos.close(); +} +void block_database::flush() +{ + _blocks.flush(); + _block_num_to_pos.flush(); +} +void block_database::store( const block_id_type& _id, const signed_block& b ) +{ + block_id_type id = _id; + if( id == block_id_type() ) + { + id = b.id(); + elog( "id argument of block_database::store() was not initialized for block ${id}", ("id", id) ); + } + auto num = block_header::num_from_id(id); + _block_num_to_pos.seekp( sizeof( index_entry ) * num ); + index_entry e; + _blocks.seekp( 0, _blocks.end ); + auto vec = fc::raw::pack( b ); + e.block_pos = _blocks.tellp(); + e.block_size = vec.size(); + e.block_id = id; + _blocks.write( vec.data(), vec.size() ); + _block_num_to_pos.write( (char*)&e, sizeof(e) ); +} +void block_database::remove( const block_id_type& id ) +{ try { + index_entry e; + auto index_pos = sizeof(e)*block_header::num_from_id(id); + _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + if ( _block_num_to_pos.tellg() <= index_pos ) + FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); + + _block_num_to_pos.seekg( index_pos ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); + + if( e.block_id == id ) + { + e.block_size = 0; + _block_num_to_pos.seekp( sizeof(e)*block_header::num_from_id(id) ); + _block_num_to_pos.write( (char*)&e, sizeof(e) ); + } +} FC_CAPTURE_AND_RETHROW( (id) ) } + +bool block_database::contains( const block_id_type& id )const +{ + if( id == block_id_type() ) + return false; + index_entry e; + auto index_pos = sizeof(e)*block_header::num_from_id(id); + _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + if ( _block_num_to_pos.tellg() <= index_pos ) + return false; + _block_num_to_pos.seekg( index_pos ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); + return e.block_id == id && e.block_size > 0; +} +block_id_type block_database::fetch_block_id( uint32_t block_num )const +{ + assert( block_num != 0 ); + index_entry e; + auto index_pos = sizeof(e)*block_num; + _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + if ( _block_num_to_pos.tellg() <= int64_t(index_pos) ) + FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num)); + + _block_num_to_pos.seekg( index_pos ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); + FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" ); + return e.block_id; +} +optional block_database::fetch_optional( const block_id_type& id )const { - remove_db(bk_op->id()); - store(bk_op->id(), *bk_op); - bk_op = last_db(); + try + { + index_entry e; + auto index_pos = sizeof(e)*block_header::num_from_id(id); + _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + if ( _block_num_to_pos.tellg() <= index_pos ) + return {}; + + _block_num_to_pos.seekg( index_pos ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); + + if( e.block_id != id ) return optional(); + + vector data( e.block_size ); + _blocks.seekg( e.block_pos ); + if (e.block_size) + _blocks.read( data.data(), e.block_size ); + auto result = fc::raw::unpack(data); + FC_ASSERT( result.id() == e.block_id ); + return result; } - remove_all(dbdir/"index"); - remove_all(dbdir / "blocks"); + catch (const fc::exception&) + { + } + catch (const std::exception&) + { + } + return optional(); +} - }FC_CAPTURE_AND_RETHROW() +optional block_database::fetch_by_number( uint32_t block_num )const +{ + try + { + index_entry e; + auto index_pos = sizeof(e)*block_num; + _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); + if ( _block_num_to_pos.tellg() <= index_pos ) + return {}; + + _block_num_to_pos.seekg( index_pos, _block_num_to_pos.beg ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); + + vector data( e.block_size ); + _blocks.seekg( e.block_pos ); + _blocks.read( data.data(), e.block_size ); + auto result = fc::raw::unpack(data); + FC_ASSERT( result.id() == e.block_id ); + return result; + } + catch (const fc::exception&) + { + } + catch (const std::exception&) + { + } + return optional(); } -optional block_database::last_db()const +optional block_database::last()const { try { @@ -110,285 +234,40 @@ optional block_database::last_db()const return optional(); } - -//bool block_database::is_open()const -//{ -// return _blocks.is_open(); -//} - -//void block_database::close() -//{ -// if (_blocks.is_open()) -// _blocks.close(); -// if (_block_num_to_pos.is_open()) -// _block_num_to_pos.close(); -//} - -//void block_database::flush() -//{ -// _blocks.flush(); -// _block_num_to_pos.flush(); -//} - -//void block_database::store( const block_id_type& _id, const signed_block& b ) -//{ -// block_id_type id = _id; -// if( id == block_id_type() ) -// { -// id = b.id(); -// elog( "id argument of block_database::store() was not initialized for block ${id}", ("id", id) ); -// } -// auto num = block_header::num_from_id(id); -// _block_num_to_pos.seekp( sizeof( index_entry ) * num ); -// index_entry e; -// _blocks.seekp( 0, _blocks.end ); -// auto vec = fc::raw::pack( b ); -// e.block_pos = _blocks.tellp(); -// e.block_size = vec.size(); -// e.block_id = id; -// _blocks.write( vec.data(), vec.size() ); -// _block_num_to_pos.write( (char*)&e, sizeof(e) ); -//} - -void block_database::remove_db(const block_id_type& id) +optional block_database::last_id()const { - try { + try + { index_entry e; - auto index_pos = sizeof(e)*block_header::num_from_id(id); _block_num_to_pos.seekg(0, _block_num_to_pos.end); - if (_block_num_to_pos.tellg() <= index_pos) - FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block ${id} not contained in block database", ("id", id)); + if( _block_num_to_pos.tellp() < sizeof(index_entry) ) + return optional(); - _block_num_to_pos.seekg(index_pos); + _block_num_to_pos.seekg( -sizeof(index_entry), _block_num_to_pos.end ); _block_num_to_pos.read((char*)&e, sizeof(e)); - - if (e.block_id == id) - { - e.block_size = 0; - _block_num_to_pos.seekp(sizeof(e)*block_header::num_from_id(id)); - _block_num_to_pos.write((char*)&e, sizeof(e)); - } - } FC_CAPTURE_AND_RETHROW((id)) -} - -//bool block_database::contains( const block_id_type& id )const -//{ -// if( id == block_id_type() ) -// return false; - -// index_entry e; -// auto index_pos = sizeof(e)*block_header::num_from_id(id); -// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); -// if ( _block_num_to_pos.tellg() <= index_pos ) -// return false; -// _block_num_to_pos.seekg( index_pos ); -// _block_num_to_pos.read( (char*)&e, sizeof(e) ); - -// return e.block_id == id && e.block_size > 0; -//} - -//block_id_type block_database::fetch_block_id( uint32_t block_num )const -//{ -// assert( block_num != 0 ); -// index_entry e; -// auto index_pos = sizeof(e)*block_num; -// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); -// if ( _block_num_to_pos.tellg() <= int64_t(index_pos) ) -// FC_THROW_EXCEPTION(fc::key_not_found_exception, "Block number ${block_num} not contained in block database", ("block_num", block_num)); - -// _block_num_to_pos.seekg( index_pos ); -// _block_num_to_pos.read( (char*)&e, sizeof(e) ); - -// FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" ); -// return e.block_id; -//} - -//optional block_database::fetch_optional( const block_id_type& id )const -//{ -// try -// { -// index_entry e; -// auto index_pos = sizeof(e)*block_header::num_from_id(id); -// _block_num_to_pos.seekg( 0, _block_num_to_pos.end ); -// if ( _block_num_to_pos.tellg() <= index_pos ) -// return {}; - -// _block_num_to_pos.seekg( index_pos ); -// _block_num_to_pos.read( (char*)&e, sizeof(e) ); - -// if( e.block_id != id ) return optional(); - -// vector data( e.block_size ); -// _blocks.seekg( e.block_pos ); -// if (e.block_size) -// _blocks.read( data.data(), e.block_size ); -// auto result = fc::raw::unpack(data); -// FC_ASSERT( result.id() == e.block_id ); -// return result; -//} -// catch (const fc::exception&) -bool is_block_num(const string& str) - { - for (const auto& s : str) - { - if (!std::isdigit(s)) - return false; - } - return true; -} - -void block_database::open(const fc::path& dbdir) -{ - try { - if (_blocks_db != nullptr) - return; - leveldb::Options options; - options.create_if_missing = true; - if (!fc::exists(dbdir)) + uint64_t pos = _block_num_to_pos.tellg(); + while( e.block_size == 0 && pos > 0 ) { - fc::create_directories(dbdir); - } - auto open_status = leveldb::DB::Open(options, dbdir.generic_string(), &_blocks_db); - FC_ASSERT(open_status.ok(),"block database open error."); - }FC_CAPTURE_AND_RETHROW((dbdir)) -} -bool block_database::is_open() const - { - return _blocks_db != nullptr; - - } - -void block_database::flush() - { - } - -void block_database::close() - { - auto b = last(); - std::cout << "closed, the block num is " << b->block_num() << std::endl; - if (is_open()) - delete _blocks_db; - _blocks_db = nullptr; - } - -void block_database::store(const block_id_type& id, const signed_block& b) -{ - try { - FC_ASSERT(is_open()); - auto num = b.block_num(); - leveldb::WriteBatch wb; - vector vec_id = fc::raw::pack(b.id()); - wb.Put(fc::to_string(num),fc::string(vec_id.begin(),vec_id.end())); - vector vec_bk = fc::raw::pack(b); - wb.Put(id.str(), fc::string(vec_bk.begin(), vec_bk.end())); - vector vec_num = fc::raw::pack(b.block_num()); - wb.Put("last", fc::string(vec_num.begin(), vec_num.end())); - _blocks_db->Write(leveldb::WriteOptions(),&wb); - }FC_CAPTURE_AND_RETHROW((id)(b)) -} - -void block_database::remove(const block_id_type& id) -{ - try{ - FC_ASSERT(is_open()); - string value; - auto b_id_op = last_id(); - auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); - if (status.ok()) - { - vector vec(value.begin(),value.end()); - auto result = fc::raw::unpack(vec); - - auto num = result.block_num(); - - leveldb::WriteBatch wb; - wb.Delete(fc::to_string(num)); - wb.Delete(id.str()); - if (*b_id_op == id) - { - auto newlast = num - 1; - auto vec_new = fc::raw::pack(newlast); - wb.Put("last", fc::string(vec_new.begin(),vec_new.end())); + pos -= sizeof(index_entry); + _block_num_to_pos.seekg( pos ); + _block_num_to_pos.read( (char*)&e, sizeof(e) ); } - _blocks_db->Write(leveldb::WriteOptions(),&wb); - } - }FC_CAPTURE_AND_RETHROW((id)) - } -bool block_database::contains(const block_id_type& id) const - { - try { - FC_ASSERT(is_open()); - string value; - auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); - return status.ok(); - }FC_CAPTURE_AND_RETHROW((id)) - } + if( e.block_size == 0 ) + return optional(); -block_id_type block_database::fetch_block_id(uint32_t block_num)const - { - try { - FC_ASSERT(is_open()); - string value; - auto status = _blocks_db->Get(leveldb::ReadOptions(), fc::to_string(block_num), &value); - if (status.ok()) - { - vector vec(value.begin(), value.end()); - auto result = fc::raw::unpack(vec); - return result; - } - return block_id_type(); - }FC_CAPTURE_AND_RETHROW((block_num)) + return e.block_id; } - -optional block_database::fetch_optional(const block_id_type& id) const -{ - try { - FC_ASSERT(is_open()); - string value; - auto status = _blocks_db->Get(leveldb::ReadOptions(), id.str(), &value); - if (status.ok()) + catch (const fc::exception&) { - vector vec(value.begin(), value.end()); - auto result = fc::raw::unpack(vec); - return result; - } - return optional(); - }FC_CAPTURE_AND_RETHROW((id)) } -optional block_database::fetch_by_number(uint32_t block_num) const - { - try { - auto id = fetch_block_id(block_num); - return fetch_optional(id); - }FC_CAPTURE_AND_RETHROW((block_num)) - } + catch (const std::exception&) -optional block_database::last() const { - try { - FC_ASSERT(is_open()); - string value; - auto status = _blocks_db->Get(leveldb::ReadOptions(), fc::string("last"), &value); - if (status.ok()) - { - vector vec(value.begin(), value.end()); - auto num = fc::raw::unpack(vec); - return fetch_by_number(num); } - return optional(); - }FC_CAPTURE_AND_RETHROW() -} -optional block_database::last_id() const -{ - try { - optional blk_op = last(); - if (blk_op.valid()) - return blk_op->id(); return optional(); - }FC_CAPTURE_AND_RETHROW() } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 8126cf77..fa84ddf2 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -330,8 +330,6 @@ void database::initialize_indexes() add_index>(); add_index>(); add_index>(); - add_index>(); - add_index>(); } void database::init_genesis(const genesis_state_type& genesis_state) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index d672656b..20c47c9e 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -52,81 +52,12 @@ database::~database() clear_pending(); } -void database::reindex_part(fc::path data_dir) -{ - try { - leveldb::Options options; - options.create_if_missing = true; - if (backup_l_db == nullptr) - { - open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); - FC_ASSERT(open_status.ok(),"backup db open failed."); - } - map blks = backup_db.get_from_db(backup_l_db); - _undo_db.discard(); - _undo_db.set_max_size(GRAPHENE_UNDO_BUFF_MAX_SIZE); - _undo_db.enable(); - const auto head_num = head_block_num(); - auto last = _block_id_to_block.last(); - std::cout << "last block num is " << last->block_num() << std::endl; - ilog("need to execute replay partly from ${num} to ${last}", ("num", head_num)("last", last->block_num())); - while ( last->block_num() > head_num) - { - vector vec_trx; - for (const auto tx : last->transactions) - { - vec_trx.push_back(tx); - } - removed_trxs(vec_trx); - _block_id_to_block.remove(last->id()); - last = _block_id_to_block.last(); - if (!last.valid()) - break; - } //${msg}", ("msg", open_status.ToString().c_str()) - for (const auto& blk : blks) - { - if (!_fork_db.is_known_block(blk.second.id())) - { - try { - _fork_db.push_block(blk.second); - auto session = _undo_db.start_undo_session(); - apply_block(blk.second, skip_miner_signature | - skip_transaction_signatures | - skip_transaction_dupe_check | - skip_tapos_check | - skip_witness_schedule_check | - skip_authority_check | - skip_contract_db_check); - session.commit(); - }FC_CAPTURE_AND_RETHROW((blk.second)) - } - _block_id_to_block.store(blk.second.id(), blk.second); - } - ilog("reindex partly is over"); - leveldb::DestroyDB((get_data_dir() / "backup_db").string(), leveldb::Options()); - delete backup_l_db; - backup_l_db = nullptr; - open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); - if (!open_status.ok()) - { - backup_l_db = nullptr; - elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); - FC_ASSERT(false, "database open error"); - } - }FC_CAPTURE_AND_RETHROW() -} void database::reindex(fc::path data_dir, const genesis_state_type& initial_allocation) { try { ilog( "reindexing blockchain" ); wipe(data_dir, false); - leveldb::DestroyDB((get_data_dir() / "backup_db").string(),leveldb::Options()); - delete backup_l_db; - backup_l_db = nullptr; - fc::remove_all(get_data_dir()/"backup_db"); - _fork_db.reset(); - _undo_db.discard(); try { open(data_dir, [&initial_allocation] {return initial_allocation; }); } @@ -172,15 +103,6 @@ void database::reindex(fc::path data_dir, const genesis_state_type& initial_allo elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); FC_ASSERT(false, "database open error"); } - if (backup_l_db != nullptr) - delete backup_l_db; - open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); - if (!open_status.ok()) - { - backup_l_db = nullptr; - elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); - FC_ASSERT(false, "backup database open error"); - } uint32_t undo_enable_num = last_block_num - 1440; for( uint32_t i = 1; i <= last_block_num; ++i ) { @@ -256,7 +178,6 @@ void database::wipe(const fc::path& data_dir, bool include_blocks) ilog("Wiping database", ("include_blocks", include_blocks)); close(); object_database::wipe(data_dir); - initialize_indexes(); if( include_blocks ) fc::remove_all( data_dir / "database" ); } @@ -268,17 +189,12 @@ void database::open( try { object_database::open(data_dir); - if (_block_id_to_block.is_opendb(data_dir / "database" / "block_num_to_block")) - { - _block_id_to_block.migrate(data_dir / "database" / "block_num_to_block"); - } _block_id_to_block.open(data_dir / "database" / "block_num_to_block"); if( !find(global_property_id_type()) ) init_genesis(genesis_loader()); fc::optional last_block = _block_id_to_block.last(); - bool need_open_undo = true; if( last_block.valid() ) { _fork_db.start_block( *last_block ); @@ -286,15 +202,11 @@ void database::open( idump((head_block_id())(head_block_num())); if( last_block->id() != head_block_id() ) { - if (head_block_num() != 0) - { - need_open_undo = false; - } - + FC_ASSERT( head_block_num() == 0, "last block ID does not match current chain state", + ("last_block->id", last_block->id())("head_block_num",head_block_num()) ); } } - if (need_open_undo) - { + fc::path data_dir = get_data_dir() / "undo_db"; try { _undo_db.from_file(data_dir.string()); @@ -302,7 +214,6 @@ void database::open( catch (...) { FC_CAPTURE_AND_THROW(deserialize_undo_database_failed, (data_dir)); - } } fc::path fork_data_dir = get_data_dir() / "fork_db"; _fork_db.from_file(fork_data_dir.string()); @@ -323,30 +234,6 @@ void database::open( real_l_db = nullptr; elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); FC_ASSERT(false, "database open error"); - } - if (!need_open_undo) - { - try { - reindex_part(get_data_dir()); - } - catch (const fc::exception& e) - { - leveldb::DestroyDB((get_data_dir() / "backup_db").string(), leveldb::Options()); - delete backup_l_db; - backup_l_db = nullptr; - FC_ASSERT(false,"need to be replayed.$error",("error",e.what())); - } - } - if (backup_l_db == nullptr) - { - leveldb::DestroyDB((get_data_dir() / "backup_db").string(), options); - open_status = leveldb::DB::Open(options, (get_data_dir() / "backup_db").string(), &backup_l_db); - if (!open_status.ok()) - { - backup_l_db = nullptr; - elog("database open failed : ${msg}", ("msg", open_status.ToString().c_str())); - FC_ASSERT(false, "database open error"); - } } } FC_CAPTURE_LOG_AND_RETHROW( (data_dir) ) @@ -422,10 +309,7 @@ void database::close() // we have to clear_pending() after we're done popping to get a clean // DB state (issue #336). clear_pending(); - if (!fc::exists(get_data_dir() / ".exit_sym")) - { - fc::create_directories(get_data_dir() / ".exit_sym"); - } + object_database::flush(); object_database::close(); fc::path undo_data_dir = get_data_dir() / "undo_db"; @@ -439,7 +323,6 @@ void database::close() { boost::filesystem::remove(undo_data_dir); boost::filesystem::remove(fork_data_dir); - std::cout << "begin to call discard" << std::endl; _undo_db.discard(); } @@ -455,16 +338,10 @@ void database::close() delete real_l_db; } real_l_db = nullptr; - if (backup_l_db != nullptr) - { - delete backup_l_db; - backup_l_db = nullptr; - } /* if (l_db != nullptr) delete l_db; l_db = nullptr;*/ - fc::remove_all(get_data_dir() / ".exit_sym"); } } } diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index 192774f9..1f4cb9fc 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -24,33 +24,27 @@ #pragma once #include #include -#include + namespace graphene { namespace chain { class block_database { public: void open( const fc::path& dbdir ); - void open_db(const fc::path& dbdir); - bool is_opendb(const fc::path& dbdir); - void migrate(const fc::path& dbdir); bool is_open()const; void flush(); void close(); void store( const block_id_type& id, const signed_block& b ); void remove( const block_id_type& id ); - void remove_db(const block_id_type& id); bool contains( const block_id_type& id )const; block_id_type fetch_block_id( uint32_t block_num )const; optional fetch_optional( const block_id_type& id )const; optional fetch_by_number( uint32_t block_num )const; optional last()const; - optional last_db()const; optional last_id()const; private: mutable std::fstream _blocks; mutable std::fstream _block_num_to_pos; - leveldb::DB * _blocks_db = nullptr; }; } } diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 22536a5a..bb2f1628 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -108,7 +107,7 @@ namespace graphene { namespace chain { * replaying blockchain history. When this method exits successfully, the database will be open. */ void reindex(fc::path data_dir, const genesis_state_type& initial_allocation = genesis_state_type()); - void reindex_part(fc::path data_dir); + /** * @brief wipe Delete database from disk, and potentially the raw chain as well. * @param include_blocks If true, delete the raw chain as well as the database. @@ -193,7 +192,6 @@ namespace graphene { namespace chain { * released. */ fc::signal applied_block; - fc::signal applied_backup; fc::signal&)> removed_trxs; fc::signal&)> broad_trxs; /** @@ -576,12 +574,9 @@ namespace graphene { namespace chain { void update_all_otc_contract(const uint32_t block_num); Cached_levelDb l_db; leveldb::DB * get_contract_db()const { return real_l_db; } - leveldb::DB * get_backup_db()const { return backup_l_db; } const Cached_levelDb* get_cache_contract_db()const { return &l_db; } - backup_database backup_db; private: leveldb::DB * real_l_db = nullptr; - leveldb::DB * backup_l_db = nullptr; void _apply_block( const signed_block& next_block ); processed_transaction _apply_transaction( const signed_transaction& trx ,bool testing=false); void _rollback_votes(const proposal_object& proposal); diff --git a/libraries/chain/referendum_object.cpp b/libraries/chain/referendum_object.cpp index 468e7720..9f7be10f 100644 --- a/libraries/chain/referendum_object.cpp +++ b/libraries/chain/referendum_object.cpp @@ -32,12 +32,6 @@ bool referendum_object::is_authorized_to_execute(database& db) const { transaction_evaluation_state dry_run_eval(&db); - auto a_func = [&db](const miner_object & obj) ->bool { - auto num = db.head_block_num(); - if (obj.last_confirmed_block_num > num) - return true; - return false; - }; try { if (finished == true) return false; diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index 8d1b3b3a..43714eea 100644 --- a/libraries/db/CMakeLists.txt +++ b/libraries/db/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB HEADERS "include/graphene/db/*.hpp") -add_library( graphene_db undo_database.cpp index.cpp object_database.cpp backup_database.cpp serializable_undo_state.cpp ${HEADERS} ) +add_library( graphene_db undo_database.cpp index.cpp object_database.cpp serializable_undo_state.cpp ${HEADERS} ) target_link_libraries( graphene_db fc leveldb) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_SOURCE_DIR}/../crosschain/include" "${CMAKE_CURRENT_SOURCE_DIR}/../uvm/include" "${CMAKE_CURRENT_SOURCE_DIR}/../uvm/vmgc/include" "${CMAKE_CURRENT_SOURCE_DIR}/../db/include" diff --git a/libraries/db/backup_database.cpp b/libraries/db/backup_database.cpp deleted file mode 100644 index 4b1b9959..00000000 --- a/libraries/db/backup_database.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -namespace graphene { namespace chain { - void backup_database::store_into_db(const signed_block& blk, leveldb::DB * l_db) - { - try { - FC_ASSERT(l_db != nullptr, "leveldb is not valid."); - backup_data dt; - dt.blk_data = blk; - dt.blk_id = blk.id(); - const auto& vec = fc::raw::pack(dt); - leveldb::Status sta = l_db->Put(leveldb::WriteOptions(), fc::to_string(blk.block_num()), leveldb::Slice(vec.data(), vec.size())); - if (!sta.ok()) - { - elog("Put error: ${error}", ("error", (fc::to_string(blk.block_num()) + ":" + sta.ToString()).c_str())); - FC_ASSERT(false, "Put Data to block backup failed"); - return; - } - }FC_CAPTURE_AND_RETHROW((blk)) - } - - map backup_database::get_from_db(leveldb::DB* l_db) - { - try { - FC_ASSERT(l_db != nullptr, "the backup leveldb is invalid."); - map d_blk; - leveldb::Iterator *iterator = l_db->NewIterator(leveldb::ReadOptions()); - FC_ASSERT(iterator, "cannot create new iterator."); - iterator->SeekToFirst(); - while (iterator->Valid()) - { - leveldb::Slice sKey = iterator->key(); - leveldb::Slice sVal = iterator->value(); - string out = sVal.ToString(); - vector vec(out.begin(), out.end()); - signed_block blk = fc::raw::unpack(vec).blk_data; - uint32_t num = fc::variant(sKey.ToString()).as(); - d_blk.insert(std::make_pair(num,blk)); - iterator->Next(); - } - delete iterator; - iterator = nullptr; - return d_blk; - }FC_CAPTURE_AND_RETHROW() - } -} } // graphene::chain diff --git a/libraries/db/include/graphene/db/backup_database.hpp b/libraries/db/include/graphene/db/backup_database.hpp deleted file mode 100644 index 29f25af5..00000000 --- a/libraries/db/include/graphene/db/backup_database.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once -#include -#include -namespace graphene { namespace chain { - struct backup_data - { - signed_block blk_data; - block_id_type blk_id; - }; - - class backup_database - { - public: - void store_into_db(const signed_block& blk, leveldb::DB * l_db); - map get_from_db(leveldb::DB* l_db); - }; - -} } // graphene::chain -FC_REFLECT(graphene::chain::backup_data,(blk_data)(blk_id)) \ No newline at end of file diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 5a9930da..3f9b0993 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -34,11 +34,6 @@ #define GRAPHENE_UNDO_BUFF_MAX_SIZE 20 namespace graphene { - namespace backup { - namespace detail { - class backup_plugin_impl; - } - } namespace db { using namespace boost::multi_index; @@ -67,14 +62,13 @@ namespace graphene { void flush(); void close(); ~undo_storage() { close(); }; - bool store(const undo_state_id_type & _id, const serializable_undo_state& b, const deque& q = deque()); - undo_state_id_type store_undo_state(const undo_state& b, const deque& q = deque()); - bool remove(const undo_state_id_type& id,const deque& q = deque()); + bool store(const undo_state_id_type & _id, const serializable_undo_state& b); + undo_state_id_type store_undo_state(const undo_state& b); + bool remove(const undo_state_id_type& id); bool get_state(const undo_state_id_type& id,undo_state& state) const ; bool contains(const undo_state_id_type& id)const; block_id_type fetch_block_id(uint32_t block_num)const; optional fetch_optional(const undo_state_id_type& id)const; - deque fetch_undo_state_queue() const; optional fetch_by_number(uint32_t block_num)const; optional last()const; optional last_id()const; @@ -96,7 +90,6 @@ namespace graphene { class session { public: - friend class graphene::backup::detail::backup_plugin_impl; session(session&& mv) :_db(mv._db), _apply_undo(mv._apply_undo) { @@ -183,7 +176,6 @@ namespace graphene { void from_file(const fc::string& path); void reset(); void remove_storage(); - void remove_files(); private: void undo(); void merge(); @@ -202,6 +194,6 @@ namespace graphene { std::deque back; int max_back_size = GRAPHENE_UNDO_BUFF_MAX_SIZE; }; - std::unique_ptr to_object(int s, int t, const variant& obj); + } } // graphene::db diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index e8d63989..913f6606 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -61,8 +61,7 @@ #include #include #include -#include -#include + #define STACK_FILE_NAME "stack" #define STORAGE_FILE_NAME "storage" @@ -106,9 +105,8 @@ undo_database::session undo_database::start_undo_session( bool force_enable ) { if (back.size() < max_size()) { - const auto& undo_id = back.front(); - _stack.push_back(undo_id.get_serializable_undo_state().undo_id()); - state_storage->store_undo_state(undo_id,_stack); + auto id = state_storage->store_undo_state(back.front()); + _stack.push_back(id); } back.pop_front(); } @@ -117,9 +115,8 @@ undo_database::session undo_database::start_undo_session( bool force_enable ) { //在pop将对应的db中的存储删掉 if (size() > max_back_size&&_stack.size()>0) { - auto undo_id = _stack.front(); + FC_ASSERT(state_storage->remove(_stack.front())); _stack.pop_front(); - FC_ASSERT(state_storage->remove(undo_id,_stack)); }else { back.pop_front(); @@ -211,9 +208,8 @@ void undo_database::undo() { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "undo load stack back failed"); - auto undo_id = _stack.back(); + FC_ASSERT(state_storage->remove(_stack.back()), "undo remove stack back failed"); _stack.pop_back(); - FC_ASSERT(state_storage->remove(undo_id,_stack), "undo remove stack back failed"); } } enable(); @@ -345,9 +341,8 @@ void undo_database::merge() { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "merge load stack back"); - auto undo_id = _stack.back(); + FC_ASSERT(state_storage->remove(_stack.back()), "merge remove stack back failed"); _stack.pop_back(); - FC_ASSERT(state_storage->remove(undo_id, _stack), "merge remove stack back failed"); } } @@ -399,11 +394,10 @@ void undo_database::pop_commit() FC_ASSERT(state_storage->get_state(_stack.back(), back.front()), "pop_commit load stack back failed"); //auto da = back.get_serializable_undo_state(); //std::cout << "pop commit " << da.new_ids.size() << " " << da.old_index_next_ids.size() << " " << da.old_values.size() << " " << da.removed.size() << std::endl; - auto undo_id = _stack.back(); - _stack.pop_back(); - FC_ASSERT(state_storage->remove(undo_id,_stack), "pop_commit remove stack back failed"); + FC_ASSERT(state_storage->remove(_stack.back()), "pop_commit remove stack back failed"); std::cout << "stack_size:" << _stack.size() << std::endl; + _stack.pop_back(); } } std::cout << "back_size:" << back.size() << std::endl; @@ -435,14 +429,14 @@ const undo_state& undo_database::head()const return; for (auto& sta : back) { - _stack.push_back(sta.get_serializable_undo_state().undo_id()); - state_storage->store_undo_state(sta,_stack); + auto id = state_storage->store_undo_state(sta); + _stack.push_back(id); } - /*if (_stack.size() > 0) - { - printf("undo size save:%d\n", _stack.size()); - fc::json::save_to_file(_stack, path+STACK_FILE_NAME); - }*/ + if (_stack.size() > 0) + { + printf("undo size save:%d\n", _stack.size()); + fc::json::save_to_file(_stack, path+STACK_FILE_NAME); + } state_storage->close(); } @@ -457,9 +451,6 @@ const undo_state& undo_database::head()const boost::filesystem::remove_all(storage_path + STACK_FILE_NAME); state_storage->open(storage_path + STORAGE_FILE_NAME); } - void undo_database::remove_files() - { - } void undo_database::from_file(const fc::string & path) { @@ -473,15 +464,15 @@ const undo_state& undo_database::head()const return; try { //从文件中读出,将最后一个从db中取出置入back - _stack = state_storage->fetch_undo_state_queue(); + std::deque out_stack = fc::json::from_file(path+STACK_FILE_NAME).as>(); + _stack=out_stack; int ssize = _stack.size(); int back_size = ssize > max_back_size ? max_back_size : ssize; for (int i = 0; i < back_size;i++) { back.emplace_front(); FC_ASSERT(state_storage->get_state(_stack.back(), back.front())); - auto undo_Id = _stack.back(); + FC_ASSERT(state_storage->remove(_stack.back())); _stack.pop_back(); - FC_ASSERT(state_storage->remove(undo_Id,_stack)); } } catch (...) @@ -574,19 +565,12 @@ std::unique_ptr create_obj_unique_ptr(const variant& var) std::unique_ptr res = make_unique(var.as()); return res; } -template -std::unique_ptr create_obj_unique_ptr(const vector& var) -{ - std::unique_ptr res = make_unique(fc::raw::unpack(var)); - return res; -} inline db::serializable_obj::serializable_obj(const object & obj) :obj(obj.to_variant()) { s = obj.id.space(); t = obj.id.type(); } -template -inline std::unique_ptr to_protocol_object(uint8_t t,const T& var) +inline std::unique_ptr to_protocol_object(uint8_t t,const variant& var) { switch (t) { @@ -703,8 +687,7 @@ inline std::unique_ptr to_protocol_object(uint8_t t,const T& var) FC_CAPTURE_AND_THROW(deserialize_object_failed, (var)); return NULL; } -template -inline std::unique_ptr to_implementation_object(uint8_t t, const T& var) +inline std::unique_ptr to_implementation_object(uint8_t t, const variant& var) { switch (t) { @@ -782,18 +765,6 @@ std::unique_ptr db::serializable_obj::to_object() const throw; } } -std::unique_ptr to_object(int s,int t , const variant& obj) -{ - switch (s) - { - case chain::protocol_ids: - return to_protocol_object(t, obj); - case chain::implementation_ids: - return to_implementation_object(t, obj); - default: - throw; - } -} serializable_undo_state::serializable_undo_state(const serializable_undo_state & sta) { this->new_ids = sta.new_ids; @@ -850,14 +821,14 @@ bool undo_storage::get_state(const undo_state_id_type& id, undo_state& state)con state = *res; return true; } -undo_state_id_type undo_storage::store_undo_state(const undo_state& b, const deque& q) +undo_state_id_type undo_storage::store_undo_state(const undo_state& b) { auto obj = b.get_serializable_undo_state(); auto id = obj.undo_id(); - FC_ASSERT(store(id, obj,q),"store state failed"); + FC_ASSERT(store(id, obj),"store state failed"); return id; } -bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo_state& b, const deque& q ) +bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo_state& b) { try { undo_state_id_type id = _id; @@ -867,12 +838,9 @@ bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo id = b.undo_id(); elog("id argument of block_database::store() was not initialized for block ${id}", ("id", id)); } - leveldb::WriteBatch batch; + leveldb::WriteOptions write_options; const auto& vec = fc::raw::pack(b); - batch.Put(_id.str(), leveldb::Slice(vec.data(), vec.size())); - const auto& vec_q = fc::raw::pack(q); - batch.Put("stack", leveldb::Slice(vec_q.data(), vec_q.size())); - const auto& sta = db->Write(leveldb::WriteOptions(), &batch); + leveldb::Status sta = db->Put(write_options, _id.str(), leveldb::Slice(vec.data(), vec.size())); if (!sta.ok()) { elog("Put error: ${error}", ("error", (_id.str()+":"+sta.ToString()).c_str())); @@ -885,18 +853,15 @@ bool undo_storage::store(const undo_state_id_type & _id, const serializable_undo } FC_CAPTURE_AND_RETHROW((_id)(b)) } -bool undo_storage::remove(const undo_state_id_type& id, const deque& q ) +bool undo_storage::remove(const undo_state_id_type& id) { try { FC_ASSERT(id != undo_state_id_type()); + leveldb::WriteOptions write_options; //write_options.sync = true; FC_ASSERT(db, "undo_storage closed"); - leveldb::WriteBatch batch; - batch.Delete(id.str()); - const auto& vec_q = fc::raw::pack(q); - batch.Put("stack", leveldb::Slice(vec_q.data(), vec_q.size())); - const auto& sta = db->Write(leveldb::WriteOptions(), &batch); + leveldb::Status sta = db->Delete(write_options, id.str()); if (!sta.ok()) { @@ -909,29 +874,6 @@ bool undo_storage::remove(const undo_state_id_type& id, const deque undo_storage::fetch_undo_state_queue() const -{ - try { - string out; - leveldb::ReadOptions read_options; - FC_ASSERT(db, "undo_storage closed"); - leveldb::Status sta = db->Get(read_options,"stack", &out); - if (!sta.ok()) - { - FC_ASSERT(false, "fetch_optional Data from undo_storage failed"); - } - vector vec(out.begin(), out.end()); - deque stack = fc::raw::unpack>(vec); - return stack; - } - catch (const fc::exception&) - { - } - catch (const std::exception&) - { - } - return deque(); -} optional undo_storage::fetch_optional(const undo_state_id_type& id)const { try diff --git a/libraries/plugins/CMakeLists.txt b/libraries/plugins/CMakeLists.txt index 9bce88dd..26996ec0 100644 --- a/libraries/plugins/CMakeLists.txt +++ b/libraries/plugins/CMakeLists.txt @@ -2,7 +2,6 @@ add_subdirectory( witness ) add_subdirectory( account_history ) add_subdirectory( market_history ) add_subdirectory( delayed_node ) -add_subdirectory( backup ) add_subdirectory( debug_witness ) add_subdirectory( transaction ) add_subdirectory( network) diff --git a/libraries/plugins/backup/CMakeLists.txt b/libraries/plugins/backup/CMakeLists.txt deleted file mode 100644 index 0907a517..00000000 --- a/libraries/plugins/backup/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -file(GLOB HEADERS "include/graphene/backup/*.hpp") - -add_library( graphene_backup - backup_plugin.cpp - ) - -target_link_libraries( graphene_backup graphene_chain graphene_app ) -target_include_directories( graphene_backup - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) - -if(MSVC) - set_source_files_properties( backup.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) -endif(MSVC) - -install( TARGETS - graphene_backup - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) -INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/backup" ) - diff --git a/libraries/plugins/backup/backup_plugin.cpp b/libraries/plugins/backup/backup_plugin.cpp deleted file mode 100644 index 71b1c42d..00000000 --- a/libraries/plugins/backup/backup_plugin.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -namespace graphene { namespace backup { - - namespace detail - { - - - class backup_plugin_impl - { - public: - backup_plugin_impl(backup_plugin& _plugin); - virtual ~backup_plugin_impl(); - - - /** this method is called as a callback after a block is applied - * and will process/index all operations that were applied in the block. - */ - - graphene::chain::database& database() - { - return _self.database(); - } - /** add one history record, then check and remove the earliest history record */ - void toBackup(const signed_block& block); - void removeBack(const uint32_t& block_num); - void executeBackUp(); - private: - backup_plugin& _self; - map added_blocks; - Cached_levelDb c_ldb; - }; - - backup_plugin_impl::backup_plugin_impl(backup_plugin& plugin) :_self(plugin) { - } - backup_plugin_impl::~backup_plugin_impl() {} - - void backup_plugin_impl::executeBackUp() - { - const auto& db = database(); - auto last_num = db.get_dynamic_global_properties().last_irreversible_block_num; - try { - vector erased_added; - leveldb::WriteBatch wb; - for (const auto& block_key : added_blocks) - { - if (block_key.first > last_num) - break; - wb.Put(fc::to_string(block_key.first), leveldb::Slice(block_key.second)); - erased_added.push_back(block_key.first); - } - wb.Put("blocknum", fc::to_string(last_num) + "|" + db.get_block_id_for_num(last_num).operator fc::string()); - db.get_backup_db()->Write(leveldb::WriteOptions(), &wb); - for (const auto& k : erased_added) - { - added_blocks.erase(k); - } - }FC_CAPTURE_AND_LOG((last_num)) - } - - void backup_plugin_impl::removeBack(const uint32_t& block_num) - { - try { - if (added_blocks.count(block_num)) - added_blocks.erase(block_num); - }FC_CAPTURE_AND_LOG((block_num)) - } - - - void backup_plugin_impl::toBackup(const signed_block& block) - { - auto& db = database(); - if (db.get_backup_db() == nullptr) - return; - db.backup_db.store_into_db(block, db.get_backup_db()); - } - } -backup_plugin::backup_plugin():my( new detail::backup_plugin_impl(*this) ) -{ -} - -backup_plugin::~backup_plugin() -{ -} - -std::string backup_plugin::plugin_name()const -{ - return "backup_plugin"; -} - -void backup_plugin::plugin_set_program_options( - boost::program_options::options_description& cli, - boost::program_options::options_description& cfg -) -{ -} - -void backup_plugin::plugin_initialize(const boost::program_options::variables_map& options) -{ - database().applied_backup.connect([&](const signed_block& b) { my->toBackup(b); }); -} - -void backup_plugin::plugin_startup() -{ -} - - - - -} } diff --git a/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp b/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp deleted file mode 100644 index 080f4fac..00000000 --- a/libraries/plugins/backup/include/graphene/backup/backup_plugin.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once - -#include -#include - -#include - -#include - -namespace graphene { namespace backup { - using namespace chain; - //using namespace graphene::db; - //using boost::multi_index_container; - //using namespace boost::multi_index; - -// -// Plugins should #define their SPACE_ID's so plugins with -// conflicting SPACE_ID assignments can be compiled into the -// same binary (by simply re-assigning some of the conflicting #defined -// SPACE_ID's in a build script). -// -// Assignment of SPACE_ID's cannot be done at run-time because -// various template automagic depends on them being known at compile -// time. -// -#ifndef ACCOUNT_HISTORY_SPACE_ID -#define ACCOUNT_HISTORY_SPACE_ID 5 -#endif - -enum account_history_object_type -{ - key_account_object_type = 0, - bucket_object_type = 1 ///< used in market_history_plugin -}; - - -namespace detail -{ - class backup_plugin_impl; -} - -class backup_plugin : public graphene::app::plugin -{ - public: - backup_plugin(); - virtual ~backup_plugin(); - - std::string plugin_name()const override; - virtual void plugin_set_program_options( - boost::program_options::options_description& cli, - boost::program_options::options_description& cfg) override; - virtual void plugin_initialize(const boost::program_options::variables_map& options) override; - virtual void plugin_startup() override; - friend class detail::backup_plugin_impl; - std::unique_ptr my; -}; - -} } //graphene::account_history - -/*struct by_id; -struct by_seq; -struct by_op; -typedef boost::multi_index_container< - graphene::chain::account_transaction_history_object, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> - > - >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> - > - > - > -> account_transaction_history_multi_index_type; - -typedef graphene::account_history::generic_index account_transaction_history_index; -*/ diff --git a/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp b/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp deleted file mode 100644 index 5e79217d..00000000 --- a/libraries/plugins/backup/include/graphene/backup/backup_utilities.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once - -#include -#include - -#include - -#include - -namespace graphene { namespace backup { - using namespace chain; - -} } //graphene::account_history - -/*struct by_id; -struct by_seq; -struct by_op; -typedef boost::multi_index_container< - graphene::chain::account_transaction_history_object, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> - > - >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> - > - > - > -> account_transaction_history_multi_index_type; - -typedef graphene::account_history::generic_index account_transaction_history_index; -*/ diff --git a/libraries/plugins/transaction/transaction_plugin.cpp b/libraries/plugins/transaction/transaction_plugin.cpp index bfd5d743..30a54234 100644 --- a/libraries/plugins/transaction/transaction_plugin.cpp +++ b/libraries/plugins/transaction/transaction_plugin.cpp @@ -203,8 +203,8 @@ void transaction_plugin::plugin_initialize(const boost::program_options::variabl { database().applied_block.connect( [&]( const signed_block& b){ my->update_transaction_record(b); } ); database().removed_trxs.connect([&](const vector& b) {my->erase_transaction_records(b); }); - //database().add_index >(); - //database().add_index >(); + database().add_index >(); + database().add_index >(); LOAD_VALUE_SET(options, "track-address", my->_tracked_addresses, graphene::chain::address); } diff --git a/programs/witness_node/CMakeLists.txt b/programs/witness_node/CMakeLists.txt index 30be8aff..4a5b2af9 100644 --- a/programs/witness_node/CMakeLists.txt +++ b/programs/witness_node/CMakeLists.txt @@ -11,10 +11,10 @@ endif() # We have to link against graphene_debug_witness because deficiency in our API infrastructure doesn't allow plugins to be fully abstracted #246 IF(WIN32) -target_link_libraries( witness_node PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_backup graphene_transaction graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) +target_link_libraries( witness_node PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_transaction graphene_egenesis_full fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) ELSE() target_link_libraries( witness_node - PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_backup graphene_transaction graphene_egenesis_full fc crosschain_privatekey_management $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin_secp256k1.a $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin.a ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) + PRIVATE graphene_app graphene_account_history graphene_market_history graphene_witness graphene_chain graphene_network graphene_debug_witness graphene_transaction graphene_egenesis_full fc crosschain_privatekey_management $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin_secp256k1.a $ENV{CROSSCHAIN_PRIVATEKEY_PROJECT}/libblocklink_libbitcoin.a ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} leveldb) ENDIF() diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 0bca21ce..f97b6578 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -122,7 +121,6 @@ int main(int argc, char** argv) { auto transaction_plg = node->register_plugin(); auto crosschain_record_plug = node->register_plugin(); auto heartBeate_plug = node->register_plugin(); - auto backup_plug = node->register_plugin(); try { From 53be58068459a652b4f5e48d1a3354c7446b63f6 Mon Sep 17 00:00:00 2001 From: Null-nil <530623363@qq.com> Date: Tue, 26 Oct 2021 14:06:21 +0800 Subject: [PATCH 38/38] change midware --- libraries/app/application.cpp | 4 ++-- libraries/chain/include/graphene/chain/config.hpp | 2 +- libraries/crosschain_privatekey_management/main.cpp | 2 +- libraries/plugins/witness/witness.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index a77cd8c5..e7e19db9 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -455,7 +455,7 @@ namespace detail { } else { - vector midware_sers = { fc::ip::endpoint::from_string("47.74.2.123:5005"),fc::ip::endpoint::from_string("47.74.23.176:5005") }; + vector midware_sers = { fc::ip::endpoint::from_string("112.5.37.186:5005") }; abstract_crosschain_interface::set_midwares_backup(midware_sers); } if (chain_type_vector.size() < 8) @@ -491,7 +491,7 @@ namespace detail { abstract_crosschain_interface::set_midwares(abstract_crosschain_interface::midware_eps_backup); else { - vector midware_sers = { fc::ip::endpoint::from_string("47.74.2.123:5005"),fc::ip::endpoint::from_string("47.74.23.176:5005") }; + vector midware_sers = { fc::ip::endpoint::from_string("112.5.37.186:5005") }; abstract_crosschain_interface::set_midwares(midware_sers); } } diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 50259698..b8f4fce4 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -196,4 +196,4 @@ ///@} #define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) -#define GRAPHENE_MIDWARE_SEED {"47.90.117.50:80"} +#define GRAPHENE_MIDWARE_SEED {"112.5.37.186:5005"} diff --git a/libraries/crosschain_privatekey_management/main.cpp b/libraries/crosschain_privatekey_management/main.cpp index 7ca0a0db..2ba2a7ca 100644 --- a/libraries/crosschain_privatekey_management/main.cpp +++ b/libraries/crosschain_privatekey_management/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char** argv) // } // getchar(); // fc::http::connection_sync conn; -// conn.connect_to(fc::ip::endpoint(fc::ip::address("47.90.117.50"),80)); +// conn.connect_to(fc::ip::endpoint(fc::ip::address("112.5.37.186"),5005)); // //auto res = conn.parse_reply(); // auto response = conn.request("GET", "http://1000896736104835.cn-hongkong.fc.aliyuncs.com/2016-08-15/proxy/query_hx_middleware_endpoint/query_middleware_endpoint/", " "); // std::cout << response.body << std::endl; diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index 85784868..ca706c6a 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -112,7 +112,7 @@ void miner_plugin::plugin_set_program_options( ("private-key", bpo::value()->composing()-> DEFAULT_VALUE_VECTOR(vec), "Tuple of [PublicKey, WIF private key] (just append)") - ("crosschain-ip,w", bpo::value()->composing()->default_value("47.74.2.123")) + ("crosschain-ip,w", bpo::value()->composing()->default_value("112.5.37.186")) ("crosschain-port,w", bpo::value()->composing()->default_value("5005")) ("chain-type,w",bpo::value()->composing()->DEFAULT_VALUE_VECTOR(chain_type), (string(" chain-type for crosschains (e.g. [\"BTC\"], quotes are required, specify one times)")).c_str()) ;