Skip to content

Commit 5305fe3

Browse files
committed
Merge branch 'feature/mergeBitrice' into 'develop'
Merge precompiled contract and other functions See merge request chainsql/chainsqld!165
2 parents 4fdcb29 + fc464f3 commit 5305fe3

File tree

27 files changed

+565
-120
lines changed

27 files changed

+565
-120
lines changed

Builds/CMake/ChainsqldCore.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ target_sources (chainsqld PRIVATE
458458
src/ripple/basics/impl/UptimeClock.cpp
459459
src/ripple/basics/impl/make_SSLContext.cpp
460460
src/ripple/basics/impl/mulDiv.cpp
461+
src/ripple/basics/impl/Sustain.cpp
461462
#[===============================[
462463
main sources:
463464
subdir: conditions

src/peersafe/app/misc/TxPool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class TxPool
168168

169169
std::shared_mutex mutable mutexSet_;
170170
std::shared_mutex mutable mutexAvoid_;
171-
171+
std::shared_mutex mutable mutexMapSynced_;
172172
std::size_t mMaxTxsInPool;
173173

174174
using TransactionSet =
@@ -185,6 +185,7 @@ class TxPool
185185

186186
sync_status mSyncStatus;
187187

188+
188189
beast::Journal j_;
189190
};
190191

src/peersafe/app/misc/impl/Executive.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ bool Executive::call(CallParametersR const& _p, uint256 const& _gasPrice, Accoun
192192
if (ter != tesSUCCESS)
193193
{
194194
m_excepted = ter;
195-
auto output = get<1>(retPre);
196-
m_output =
197-
eth::owning_bytes_ref{std::move(output), 0, output.size()};
198195
return true;
199196
}
200-
}
197+
auto output = get<1>(retPre);
198+
if (output.size() > 0)
199+
m_output = eth::owning_bytes_ref{std::move(output), 0, output.size()};
200+
}
201201
else
202202
{
203203
m_gas = _p.gas;

src/peersafe/app/misc/impl/SleOps.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,14 +531,15 @@ namespace ripple {
531531
Json::Value jvCommand, tableJson;
532532
jvCommand[jss::tx_json][jss::Owner] = to_string(_owner);
533533
jvCommand[jss::tx_json][jss::Account] = to_string(_account);
534-
Json::Value _fields(Json::arrayValue);//select fields
535-
jvCommand[jss::tx_json][jss::Raw].append(_fields);//append select fields
536534
if (!_raw.empty())//append select conditions
537535
{
538-
Json::Value _condition;
539-
Json::Reader().parse(_raw, _condition);
540-
jvCommand[jss::tx_json][jss::Raw].append(_condition);
541-
}
536+
jvCommand[jss::tx_json][jss::Raw] = _raw;
537+
}
538+
else
539+
{
540+
Json::Value _fields(Json::arrayValue); // select fields
541+
jvCommand[jss::tx_json][jss::Raw].append(_fields); // append select fields
542+
}
542543
jvCommand[jss::tx_json][jss::OpType] = R_GET;
543544
tableJson[jss::Table][jss::TableName] = _sTableName;
544545

src/peersafe/app/misc/impl/TxPool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ TxPool::removeTxs(
141141
void
142142
TxPool::checkSyncStatus(LedgerIndex ledgerSeq, uint256 const& prevHash)
143143
{
144+
std::lock_guard lock(mutexMapSynced_);
144145
// update sync_status
145146
if (mTxsSet.size() == 0)
146147
{

src/peersafe/app/table/TableSync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TableSync
5555
bool isExist(std::list<std::shared_ptr <TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType);
5656

5757
bool
58-
isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType);
58+
isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, std::string uTxDBName, TableSyncItem::SyncTargetType eTargeType);
5959

6060
//get reply
6161
bool GotSyncReply(std::shared_ptr <protocol::TMTableData> const& m, std::weak_ptr<Peer> const& wPeer);

src/peersafe/app/table/impl/TableSync.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -553,15 +553,20 @@ TableSync::ParseSyncAccount(std::string line)
553553

554554
AccountID userAccount;
555555
SecretKey secret_key;
556-
if (vec.size() == 2 && (vec[1][0] == 'p' || vec[1][0] == 'x'))
556+
if (vec.size() == 2)
557557
{
558-
auto tup = ParseSecret(vec[1], "");
559-
if (std::get<2>(tup))
558+
if ((vec[1][0] == 'p' || vec[1][0] == 'x'))
560559
{
561-
userAccount = std::get<0>(tup);
562-
secret_key = std::get<1>(tup);
560+
auto tup = ParseSecret(vec[1], "");
561+
if (std::get<2>(tup))
562+
{
563+
userAccount = std::get<0>(tup);
564+
secret_key = std::get<1>(tup);
565+
}
566+
return std::make_tuple(*oAccountID, userAccount,secret_key, true);
563567
}
564-
return std::make_tuple(*oAccountID, userAccount,secret_key, true);
568+
return std::make_tuple(*oAccountID, beast::zero, SecretKey(), false);
569+
565570
}
566571
else
567572
{
@@ -954,13 +959,12 @@ bool TableSync::isExist(std::list<std::shared_ptr <TableSyncItem>> listTableInf
954959

955960

956961
bool
957-
TableSync::isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, AccountID accountID, std::string sTableName, TableSyncItem::SyncTargetType eTargeType)
962+
TableSync::isSync(std::list<std::shared_ptr<TableSyncItem>> listTableInfo_, std::string uTxDBName, TableSyncItem::SyncTargetType eTargeType)
958963
{
959964
std::lock_guard lock(mutexlistTable_);
960965
std::list<std::shared_ptr<TableSyncItem>>::iterator iter = std::find_if(listTableInfo_.begin(),listTableInfo_.end(),
961-
[accountID, sTableName, eTargeType](std::shared_ptr<TableSyncItem> pItem) {
962-
bool bExist = (pItem->GetTableName() == sTableName) &&
963-
(pItem->GetAccount() == accountID) &&
966+
[uTxDBName, eTargeType](std::shared_ptr<TableSyncItem> pItem) {
967+
bool bExist = (pItem->TableNameInDB() == uTxDBName) &&
964968
(pItem->TargetType() == eTargeType) &&
965969
(pItem->GetSyncState() != TableSyncItem::SYNC_DELETING &&
966970
pItem->GetSyncState() != TableSyncItem::SYNC_REMOVE &&
@@ -1845,7 +1849,7 @@ void TableSync::CheckSyncTableTxs(std::shared_ptr<Ledger const> const& ledger)
18451849
bool bDBTableSync = false;
18461850
if (mapTxDBNam2Sync.find(uTxDBName) == mapTxDBNam2Sync.end())
18471851
{
1848-
bDBTableSync = isSync(listTableInfo_, accountID, tableName, TableSyncItem::SyncTarget_db);
1852+
bDBTableSync = isSync(listTableInfo_, to_string(uTxDBName), TableSyncItem::SyncTarget_db);
18491853
mapTxDBNam2Sync[uTxDBName] = bDBTableSync;
18501854
}
18511855
else
@@ -1854,7 +1858,7 @@ void TableSync::CheckSyncTableTxs(std::shared_ptr<Ledger const> const& ledger)
18541858
}
18551859
if (!bDBTableSync)
18561860
{
1857-
app_.getOPs().pubTableTxs(accountID, tableName, *pSTTX, std::make_tuple("db_acctSecretError", "", ""), false);
1861+
app_.getOPs().pubTableTxs(accountID, tableName, *pSTTX, std::make_tuple("db_notInSync", "", ""), false);
18581862
break;
18591863
}
18601864
}

src/peersafe/app/tx/impl/DirectApply.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ namespace ripple {
165165
applyDirect(Schema& app, ApplyView& view, STTx const& tx, beast::Journal j)
166166
{
167167
auto pfresult = preflight(app, view.openView().rules(), tx, view.flags()| tapNO_CHECK_SIGN, j);
168-
auto pcresult = preclaimDirect(pfresult, app, view.openView());
168+
// construct a openview copy,and apply change to it
169+
std::shared_ptr<OpenView> openView =
170+
std::make_shared<OpenView>(view.openView());
171+
((ApplyViewImpl&)view).items().apply(*openView);
172+
173+
auto pcresult = preclaimDirect(pfresult, app, *openView);
169174
auto ret = doApplyDirect(pcresult, app, view);
170175
return ret;
171176
//return doApplyDirect(pcresult, app, view);

src/peersafe/consensus/Adaptor.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,9 @@ class Adaptor
321321
bool haveCorrectLCL);
322322

323323
virtual void
324-
InitAnnounce(STInitAnnounce const& initAnnounce);
324+
InitAnnounce(
325+
STInitAnnounce const& initAnnounce,
326+
boost::optional<PublicKey> pubKey = boost::none);
325327

326328
void
327329
signMessage(protocol::TMConsensus& consensus);

src/peersafe/consensus/ConsensusBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class ConsensusBase
7878

7979
// Last validated ledger ID provided to consensus
8080
typename Ledger_t::ID prevLedgerID_;
81+
Ledger_t::Seq prevLedgerSeq_;
82+
8183
// Last validated ledger seen by consensus
8284
Ledger_t previousLedger_;
8385

0 commit comments

Comments
 (0)