本文整理汇总了C++中Transaction类的典型用法代码示例。如果您正苦于以下问题:C++ Transaction类的具体用法?C++ Transaction怎么用?C++ Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gen_rules
// Generate Transactions
//
void gen_rules(TransPar &par)
{
StringSet *lits;
StringSetIter *patterns;
Transaction *trans;
poisson_distribution<LINT> tlen(par.tlen - 1);
ofstream data_fp;
ofstream pat_fp;
data_fp.open(data_file, ios::trunc);
pat_fp.open(pat_file, ios::trunc);
lits = new StringSet(par.nitems, par.lits);
// Reset random seed generator before generating transactions
if (par.seed < 0) generator.seed(par.seed);
par.write(pat_fp);
lits->display(pat_fp);
patterns = new StringSetIter(*lits);
for (LINT i = 0; i < par.ntrans; i ++)
{
trans = mk_tran(*patterns, tlen(generator) + 1);
if (par.ascii)
trans->write_asc(data_fp);
else
trans->write(data_fp);
delete trans;
}
data_fp.close();
pat_fp.close();
}
开发者ID:rionda,项目名称:datasetgenerator,代码行数:37,代码来源:main.c
示例2: buildQueue
bool TransactionQueue::buildQueue(ifstream& transFile) {
// temporary members to store input for processing
char act;
int a1, a1t, a2, a2t, amt, tmp;
a1 = a1t = a2 = a2t = amt = tmp = 0;
transFile >> act;
//loop through file
for (;;) {
// get action indicator first to guide action
//cout << act << "|";
// test if valid action, otherwise abort for this line
if (act == 'D' || act == 'W' || act == 'M' || act == 'H') {
transFile >> tmp;
//cout << tmp << "|";
if (act == 'H') { // for History, store acct#/type & done
a1 = tmp;
} else { // all others need at least a first
a1 = tmp / 10; // acct#, acct type, and amount
a1t = tmp % 10;
transFile >> amt;
if (act == 'M') { // finally, if Move get second
transFile >> tmp; // acct# and acct type
a2 = tmp / 10;
a2t = tmp % 10;
}
}
// build object and enqueue, then move on to next line
Transaction* t = new Transaction;
t->setData(act, a1, a1t, a2, a2t, amt);
transQueue.push_back(t);
a1 = a1t = a2 = a2t = amt = tmp = 0;
} else {
开发者ID:timgalvin,项目名称:banking-system,代码行数:34,代码来源:transactionqueue.cpp
示例3: Transfer
void Bank::Transfer(const Transaction& tr)
{
Account info;
Account* from = NULL;
Account* to = NULL;
string acc = tr.GetAccount();
string num = acc.substr(0, acc.length() - 1);
info.SetNumber(num);
if (!tree.Retrieve(info, from))
{
cerr << "ERROR: Account " << num
<< " not found. Transferal refused." << endl;
return;
}
string acc2 = tr.GetAccount2();
string num2 = acc2.substr(0, acc2.length() - 1);
info.SetNumber(num2);
if (!tree.Retrieve(info, to))
{
cerr << "ERROR: Account " << num2
<< " not found. Transferal refused." << endl;
return;
}
if (from->Transfer(tr, true))
{
to->Transfer(tr, false);
}
}
开发者ID:rjrosner,项目名称:UW-BankProgram,代码行数:32,代码来源:Bank.cpp
示例4: s3fs_chown
int s3fs_chown(const char *path, uid_t uid, gid_t gid) {
#ifdef DEBUG
syslog(LOG_INFO, "chown[%s] uid[%d] gid[%d]", path, uid, gid);
#endif
try {
Transaction t;
t.getExisting(path);
// uid or gid < 0 indicates no change
if ((int) uid >= 0 && t.file->info->uid != uid) {
t.file->info->uid = uid;
t.file->dirty_metadata = true;
}
if ((int) gid >= 0 && t.file->info->gid != gid) {
t.file->info->gid = gid;
t.file->dirty_metadata = true;
}
return 0;
} catch (int e) {
syslog(LOG_INFO, "chown[%s]: %s", path, strerror(e));
return e;
}
}
开发者ID:anandu,项目名称:s3fslite,代码行数:25,代码来源:s3fs.cpp
示例5: fromAccount
void Transact::on_debug_clicked()
{
// Secret s = findSecret(value() + fee());
Address from = fromAccount();
auto b = ethereum()->balanceAt(from, PendingBlock);
if (!from || b < value() + fee())
{
QMessageBox::critical(this, "Transaction Failed", "Couldn't make transaction: account doesn't contain at least the required amount.");
return;
}
try
{
Block postState(ethereum()->postState());
Transaction t = isCreation() ?
Transaction(value(), gasPrice(), gas(), m_data, postState.transactionsFrom(from)) :
Transaction(value(), gasPrice(), gas(), toAccount().first, m_data, postState.transactionsFrom(from));
t.forceSender(from);
Debugger dw(m_main, this);
Executive e(postState, ethereum()->blockChain(), 0);
dw.populate(e, t);
dw.exec();
}
catch (dev::Exception const& _e)
{
QMessageBox::critical(this, "Transaction Failed", "Couldn't make transaction. Low-level error: " + QString::fromStdString(diagnostic_information(_e)));
// this output is aimed at developers, reconsider using _e.what for more user friendly output.
}
}
开发者ID:AndresAH,项目名称:cpp-ethereum,代码行数:29,代码来源:Transact.cpp
示例6: replaceGas
void MixClient::executeTransaction(Transaction const& _t, Block& _block, bool _call, bool _gasAuto, Secret const& _secret)
{
Transaction t = _gasAuto ? replaceGas(_t, m_postMine.gasLimitRemaining()) : _t;
// do debugging run first
EnvInfo envInfo(bc().info(), bc().lastHashes());
ExecutionResult d = debugTransaction(t, _block.state(), envInfo, _call);
// execute on a state
if (!_call)
{
t = _gasAuto ? replaceGas(_t, d.gasUsed, _secret) : _t;
eth::ExecutionResult const& er = _block.execute(envInfo.lastHashes(), t);
if (t.isCreation() && _block.state().code(d.contractAddress).empty())
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Not enough gas for contract deployment"));
d.gasUsed = er.gasUsed + er.gasRefunded + er.gasForDeposit + c_callStipend;
LocalisedLogEntries logs;
TransactionReceipt const& tr = _block.receipt(_block.pending().size() - 1);
LogEntries le = tr.log();
if (le.size())
for (unsigned j = 0; j < le.size(); ++j)
logs.insert(logs.begin(), LocalisedLogEntry(le[j]));
d.logs = logs;
}
WriteGuard l(x_executions);
m_executions.emplace_back(std::move(d));
}
开发者ID:raasakh,项目名称:cpp-ethereum,代码行数:28,代码来源:MixClient.cpp
示例7: s3fs_rmdir
int s3fs_rmdir(const char *path) {
#ifdef DEBUG
syslog(LOG_INFO, "rmdir[%s]", path);
#endif
try {
Transaction t;
t.getExisting(path);
// sync any deleted files inside this directory
Filecache::sync();
// make sure the directory is empty
std::string marker;
stringlist entries;
S3request::get_directory(path, marker, entries, 1);
if (entries.size() > 0)
throw -ENOTEMPTY;
t.file->deleted = true;
return 0;
} catch (int e) {
syslog(LOG_INFO, "rmdir[%s]: %s", path, strerror(e));
return e;
}
}
开发者ID:anandu,项目名称:s3fslite,代码行数:27,代码来源:s3fs.cpp
示例8: Transaction
// Generate a transaction
//
Transaction *mk_tran(StringSetIter &lits, // table of patterns
LINT tlen, // transaction length
LINT NPATS, Taxonomy *tax)
{
Transaction *trans;
StringP pat;
if (tlen > Transaction::MAXNITEMS)
tlen = Transaction::MAXNITEMS; //MJZ: can't exceed nitems
trans = new Transaction(tlen);
LINT patcnt = 0; //MJZ
while (trans->size() < tlen && patcnt < NPATS)
{
patcnt++;
//cout << trans->size() << " " << tlen << " HERE2\n";
pat = lits.get_pat(); // get a pattern
if (!trans->add(*pat))
{
// this pattern didn't fit in the transaction
lits.unget_pat();
break;
}
}
return trans;
}
开发者ID:Minzc,项目名称:datasetgenerator,代码行数:27,代码来源:main.CPP
示例9: apply
bool Manager::apply()
{
Transaction *tx = m_reapack->setupTransaction();
if(!tx)
return false;
if(m_autoInstall)
m_config->install()->autoInstall = m_autoInstall.value();
if(m_bleedingEdge)
m_config->install()->bleedingEdge = m_bleedingEdge.value();
for(const auto &pair : m_enableOverrides) {
const Remote &remote = pair.first;
const bool enable = pair.second;
if(m_uninstall.find(remote) == m_uninstall.end())
m_reapack->setRemoteEnabled(enable, remote);
}
for(const Remote &remote : m_uninstall)
m_reapack->uninstall(remote);
tx->runTasks();
m_config->write();
reset();
return true;
}
开发者ID:Tarasmetal,项目名称:reapack,代码行数:30,代码来源:manager.cpp
示例10: TEST_F
TEST_F(TestStream, Simple)
{
Connection c = Connection::create(m_engine);
Transaction tx = Transaction::create(c);
ib_stream_pump_t *pump;
ASSERT_EQ(IB_OK,
ib_stream_pump_create(&pump, m_reg, tx.ib())
);
ASSERT_EQ(IB_OK,
ib_stream_pump_processor_add(pump, "inflate")
);
ASSERT_EQ(IB_OK,
ib_stream_pump_processor_add(pump, "collector")
);
ASSERT_EQ(IB_OK,
ib_stream_pump_flush(pump)
);
ASSERT_EQ(IB_OK,
ib_stream_pump_process(pump, compressed_data, 3)
);
ASSERT_EQ(IB_OK,
ib_stream_pump_process(pump,
compressed_data + 3,
compressed_data_len - 3)
);
ASSERT_EQ(IB_OK,
ib_stream_pump_flush(pump)
);
ASSERT_EQ(0,
m_collector.compare(0, std::string::npos,
reinterpret_cast<const char*>(uncompressed_data),
uncompressed_data_len));
}
开发者ID:PutiZL,项目名称:ironbee,代码行数:34,代码来源:test_module_inflate.cpp
示例11: get_user_index_table
uid_t YChatDB::addUser(const string& username, const string& password) {
Storage* uind_store = get_user_index_table();
Storage* user_store = get_user_table();
if (uind_store == NULL || user_store == NULL) return 0;
Transaction txn;
uid_t uid = 0;
try {
if (!inc_and_get_curr_max_uid(uind_store, txn, uid)) {
txn.abort();
return 0;
}
OctetsStream key, value;
key << username, value << password << uid;
uind_store->insert(key, value, txn);
User user(uid, username);
OctetsStream key2, value2;
key2 << uid, value2 << user.toString();
user_store->insert(key2, value2, txn);
} catch (...) {
txn.abort();
return 0;
}
return uid;
}
开发者ID:william-cheung,项目名称:YChat,代码行数:26,代码来源:YChatDB.cpp
示例12: process_commit
void
process_commit() {
/*
Loop through all the maps and add to new map in each transaction.
Once that is done, what we have is the new final transaction.
Erase trans_stack and add this new final transaction as tid 0
*/
vector<Transaction*>::iterator t_stack_it;
map<string, int> tr_start_varMap;
map<int,int> tr_start_valMap;
Transaction *t = new Transaction(0);
Transaction* tr_start;
for (t_stack_it = trans_stack.begin(); t_stack_it != trans_stack.end(); ++t_stack_it) {
tr_start = *t_stack_it;
// get all varMap and valMapentries from tr_start to t
tr_start_varMap = tr_start->get_varMap();
//tr_start_valMap = tr_start->get_valMap();
t->populate_vmaps(tr_start_varMap);
//clear the copy buffers
tr_start_valMap.erase(tr_start_valMap.begin(), tr_start_valMap.end());
tr_start_varMap.erase(tr_start_varMap.begin(), tr_start_varMap.end());
}
trans_stack.erase(trans_stack.begin(), trans_stack.end());
trans_stack.push_back(t);
}
开发者ID:tomkaith13,项目名称:puppyDB,代码行数:29,代码来源:puppy_db.cpp
示例13: while
void TransactionHandler::work()
{
//std::lock_guard<std::mutex> guard(m);
//m.lock();
int i = 0;
while (!mQueue.empty())
{
//m.unlock();
//m.lock();
Transaction* t = mQueue.front();
mQueue.pop();
//m.unlock();
t->call();
//m1.lock();
//std::cout << std::this_thread::get_id() << ": " << i << std::endl;
//m1.unlock();
i++;
}
//delete t;
//m1.lock();
//std::cout << "I am " << std::this_thread::get_id() << " and I did " << i << " transactions. " << std::endl;
//m1.unlock();
}
开发者ID:Fibonacho,项目名称:Concurrency-Control-Manager,代码行数:27,代码来源:TransactionHandler.cpp
示例14: assert
void AspEventHandler::report_topsortedtx() {
char buff[256];
assert(ASP_ROOT != NULL);
sprintf(buff, "%s/asp/analysis/work/%s/%s", ASP_ROOT, test_name_, TRACE_FILE);
FILE* trace_file = fopen(buff, "w");
if(!trace_file) {
printf("Error in opening the trace file /tmp/trace.txt !");
exit(-1);
}
for(TransactionPtrList::iterator itr = txlist_sorted_.begin(); itr != txlist_sorted_.end(); ++itr) {
Transaction* tx = (*itr);
fprintf(report_file_, "%s\n", TXID_ToString(tx->txid()).c_str());
// write to Richard's trace file format
AccessBasePtrList* accesses = tx->accesses();
for(AccessBasePtrList::iterator iter = accesses->begin(); iter < accesses->end(); ++iter) {
AccessBase* access = (*iter);
if(access->is_array() && access->is_write()) {
fprintf(trace_file, "_asp_log_write(%s, %d, %s, %.4f)\n",
access->base_name(), access->offset(), "_my_in_img", access->double_value());
}
}
}
fclose(trace_file);
}
开发者ID:richardxia,项目名称:asp-multilevel-debug,代码行数:27,代码来源:cpp_analysis.cpp
示例15: s3fs_getattr
int s3fs_getattr(const char *path, struct stat *stbuf) {
#ifdef DEBUG
syslog(LOG_INFO, "getattr[%s]", path);
#endif
try {
Transaction t;
t.getExisting(path);
if (t.file->deleted)
throw -ENOENT;
t.file->info->toStat(stbuf);
return 0;
} catch (int e) {
if (e == -ENOENT) {
// getattr is used to check if a file exists, so
// getting a File Not Found error is nothing to worry about
#ifdef DEBUG
syslog(LOG_INFO, "getattr[%s]: File not found", path);
#endif
} else {
syslog(LOG_INFO, "getattr[%s]: %s", path, strerror(e));
}
return e;
}
}
开发者ID:anandu,项目名称:s3fslite,代码行数:28,代码来源:s3fs.cpp
示例16: s3fs_readlink
int s3fs_readlink(const char *path, char *buf, size_t size) {
#ifdef DEBUG
syslog(LOG_INFO, "readlink[%s]", path);
#endif
// save room for null at the end
size--;
if (size <= 0)
return 0;
try {
Transaction t;
t.getExisting(path);
t.getFd();
struct stat st;
if (fstat(t.file->fd, &st) < 0)
throw -errno;
if ((size_t) st.st_size < size)
size = st.st_size;
if (pread(t.file->fd, buf, size, 0) < 0)
throw -errno;
buf[size] = 0;
return 0;
} catch (int e) {
syslog(LOG_INFO, "readlink[%s]: %s", path, strerror(e));
return e;
}
}
开发者ID:anandu,项目名称:s3fslite,代码行数:33,代码来源:s3fs.cpp
示例17:
Void metadata::Transaction::RemoveNextTransactions()
{
if(!current_transaction.isValid())
return;
for(Transaction tmp = current_transaction.getNextTransactionTransaction(); tmp.isValid(); tmp = current_transaction.getNextTransactionTransaction())
tmp.destroy();
}
开发者ID:ivandzen,项目名称:HSDB,代码行数:7,代码来源:metadata_user.cpp
示例18: s3fs_truncate
int s3fs_truncate(const char *path, off_t size) {
#ifdef DEBUG
syslog(LOG_INFO, "truncate[%s] size[%llu]", path,
(unsigned long long) size);
#endif
try {
Transaction t;
t.getExisting(path);
// the easy case
if ((size_t) size == t.file->info->size)
return 0;
// we don't have it locally
if (size == 0)
t.file->info->size = 0;
// this will only download if we don't have it and size > 0
t.getFd();
if (ftruncate(t.file->fd, size) < 0)
throw -errno;
t.file->info->mtime = time(NULL);
t.file->dirty_data = true;
t.file->dirty_metadata = true;
return 0;
} catch (int e) {
syslog(LOG_INFO, "truncate[%s]: %s", path, strerror(e));
return e;
}
}
开发者ID:anandu,项目名称:s3fslite,代码行数:34,代码来源:s3fs.cpp
示例19:
bool
Budget::ChangeDate(string category, string oldtimestamp, string newtimestamp)
{
if (!_CategoryExists(category)) {
return false;
}
Category* c = _categories.find(category)->second;
// Don't do anything if the old timestamp doesn't exist
if (c->Transactions()->count(oldtimestamp) == 0) {
return false;
}
// Don't do anything if the new timestamp already exists
if (c->Transactions()->count(newtimestamp) > 0) {
return false;
}
// Temporarily remove the transaction
Transaction* t = c->Transactions()->find(oldtimestamp)->second;
c->Transactions()->erase(oldtimestamp);
// Rename it
t->SetTimestamp(newtimestamp);
c->AddTransaction(t);
return true;
}
开发者ID:drcouzelis,项目名称:divvyup,代码行数:29,代码来源:Budget.cpp
示例20: matches
bool TransactionFilter::matches(State const& _s, unsigned _i) const
{
h256 b = _s.changesFromPending(_i).bloom();
if (!matches(b))
return false;
Transaction t = _s.pending()[_i];
if (!m_to.empty() && !m_to.count(t.receiveAddress))
return false;
if (!m_from.empty() && !m_from.count(t.sender()))
return false;
if (m_stateAltered.empty() && m_altered.empty())
return true;
StateDiff d = _s.pendingDiff(_i);
if (!m_altered.empty())
{
for (auto const& s: m_altered)
if (d.accounts.count(s))
return true;
return false;
}
if (!m_stateAltered.empty())
{
for (auto const& s: m_stateAltered)
if (d.accounts.count(s.first) && d.accounts.at(s.first).storage.count(s.second))
return true;
return false;
}
return true;
}
开发者ID:AronVanAmmers,项目名称:cpp-ethereum,代码行数:30,代码来源:Client.cpp
注:本文中的Transaction类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论