本文整理汇总了C++中AccountID类的典型用法代码示例。如果您正苦于以下问题:C++ AccountID类的具体用法?C++ AccountID怎么用?C++ AccountID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AccountID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
BanManager::BanManager()
{
Result result(db->Select("SELECT * FROM bans"));
if (!result.IsValid())
return;
time_t now = time(0);
for (unsigned int i=0; i<result.Count(); i++)
{
AccountID account = AccountID(result[i].GetUInt32("account"));
time_t end = result[i].GetUInt32("end");
if (now > end) // Time served
{
db->Command("DELETE FROM bans WHERE account='%u'", account.Unbox());
continue;
}
BanEntry* newentry = new BanEntry;
newentry->account = account;
newentry->end = end;
newentry->start = result[i].GetUInt32("start");
newentry->ipRange = result[i]["ip_range"];
newentry->reason = result[i]["reason"];
newentry->banIP = result[i].GetUInt32("ban_ip") != 0;
// If account ban, add to list
if (newentry->account.IsValid())
banList_IDHash.Put(newentry->account,newentry);
// If IP range ban, add to list
if ( newentry->ipRange.Length() && newentry->banIP /*(!end || now < newentry->start + IP_RANGE_BAN_TIME)*/ )
banList_IPRList.Push(newentry);
}
}
示例2: toBase58
std::string
toBase58 (AccountID const& v)
{
return base58EncodeToken(
TOKEN_ACCOUNT_ID,
v.data(), v.size());
}
示例3: accountKey
uint256 CanonicalTXSet::accountKey (AccountID const& account)
{
uint256 ret = beast::zero;
memcpy (
ret.begin (),
account.begin (),
account.size ());
ret ^= salt_;
return ret;
}
示例4: parseHex
boost::optional<AccountID>
parseHex (std::string const& s)
{
if (s.size() != 40)
return boost::none;
AccountID id;
if (! id.SetHex(s, true))
return boost::none;
return id;
}
示例5: Answer
/*
Calculation of the Account ID
The AccountID is a 160-bit identifier that uniquely
distinguishes an account. The account may or may not
exist in the ledger. Even for accounts that are not in
the ledger, cryptographic operations may be performed
which affect the ledger. For example, designating an
account not in the ledger as a regular key for an
account that is in the ledger.
Why did we use half of SHA512 for most things but then
SHA256 followed by RIPEMD160 for account IDs? Why didn't
we do SHA512 half then RIPEMD160? Or even SHA512 then RIPEMD160?
For that matter why RIPEMD160 at all why not just SHA512 and keep
only 160 bits?
Answer (David Schwartz):
The short answer is that we kept Bitcoin's behavior.
The longer answer was that:
1) Using a single hash could leave ripple
vulnerable to length extension attacks.
2) Only RIPEMD160 is generally considered safe at 160 bits.
Any of those schemes would have been acceptable. However,
the one chosen avoids any need to defend the scheme chosen.
(Against any criticism other than unnecessary complexity.)
"The historical reason was that in the very early days,
we wanted to give people as few ways to argue that we were
less secure than Bitcoin. So where there was no good reason
to change something, it was not changed."
*/
AccountID
calcAccountID (PublicKey const& pk)
{
ripesha_hasher rsh;
rsh(pk.data(), pk.size());
auto const d = static_cast<
ripesha_hasher::result_type>(rsh);
AccountID id;
static_assert(sizeof(d) == sizeof(id), "");
std::memcpy(id.data(), d.data(), d.size());
return id;
}
示例6: STBase
STPathSet::STPathSet (SerialIter& sit, SField const& name)
: STBase(name)
{
std::vector<STPathElement> path;
for(;;)
{
int iType = sit.get8 ();
if (iType == STPathElement::typeNone ||
iType == STPathElement::typeBoundary)
{
if (path.empty ())
{
JLOG (debugLog().error())
<< "Empty path in pathset";
Throw<std::runtime_error> ("empty path");
}
push_back (path);
path.clear ();
if (iType == STPathElement::typeNone)
return;
}
else if (iType & ~STPathElement::typeAll)
{
JLOG (debugLog().error())
<< "Bad path element " << iType << " in pathset";
Throw<std::runtime_error> ("bad path element");
}
else
{
auto hasAccount = iType & STPathElement::typeAccount;
auto hasCurrency = iType & STPathElement::typeCurrency;
auto hasIssuer = iType & STPathElement::typeIssuer;
AccountID account;
Currency currency;
AccountID issuer;
if (hasAccount)
account.copyFrom (sit.get160 ());
if (hasCurrency)
currency.copyFrom (sit.get160 ());
if (hasIssuer)
issuer.copyFrom (sit.get160 ());
path.emplace_back (account, currency, issuer, hasCurrency);
}
}
}
示例7: calcAccountID
// DEPRECATED
AccountID
calcAccountID (RippleAddress const& publicKey)
{
auto const& pk =
publicKey.getAccountPublic();
ripesha_hasher rsh;
rsh(pk.data(), pk.size());
auto const d = static_cast<
ripesha_hasher::result_type>(rsh);
AccountID id;
static_assert(sizeof(d) == sizeof(id), "");
std::memcpy(id.data(), d.data(), d.size());
return id;
}
示例8: deprecatedParseBitcoinAccountID
boost::optional<AccountID>
deprecatedParseBitcoinAccountID (std::string const& s)
{
auto const result =
decodeBase58TokenBitcoin(
s, TOKEN_ACCOUNT_ID);
if (result.empty())
return boost::none;
AccountID id;
if (result.size() != id.size())
return boost::none;
std::memcpy(id.data(),
result.data(), result.size());
return id;
}
示例9: result
bool CharCreationManager::IsLastNameAvailable(const char* lastname, AccountID requestingAcct)
{
if(!lastname || strlen(lastname) < 1)
return true; // blank last names are allowed.
// Check to see if name already exists in character database.
csString query;
csString escape;
db->Escape(escape, lastname);
query.Format("SELECT account_id FROM characters WHERE lastname='%s'", escape.GetData());
Result result(db->Select(query));
if(result.IsValid())
{
if(result.Count() == 0)
return true; // nobody owns it yet, it's available
if(requestingAcct.IsValid())
{
for(unsigned int i = 0; i < result.Count(); i++)
{
if(AccountID(result[i].GetInt("account_id")) == requestingAcct)
return true; // another character on the same account; available
}
}
}
return false; // already in use by someone else
}
示例10: IsReserved
int CharCreationManager::IsReserved(const char* name, AccountID acctID)
{
// Check to see if this name is reserved. Does this check by comparing
// the email address of the account with that stored in the migration table.
csString query;
csString escape;
db->Escape(escape, name);
query.Format("SELECT m.email FROM migration m WHERE m.username='%s'", escape.GetData());
Result result(db->Select(query));
if(result.IsValid() && result.Count() == 1)
{
csString savedEmail(result[0][0]);
query.Format("SELECT username FROM accounts WHERE id=%d\n", acctID.Unbox());
Result result2(db->Select(query));
if(result2.IsValid() && result2.Count() == 1)
{
csString email(result2[0][0]);
if(savedEmail.CompareNoCase(email))
return NAME_RESERVED_FOR_YOU;
else
return NAME_RESERVED;
}
}
return NAME_AVAILABLE;
}
示例11: RemoveBan
bool BanManager::RemoveBan(AccountID account)
{
BanEntry* ban = GetBanByAccount(account);
if (!ban)
return false; // Not banned
db->Command("DELETE FROM bans WHERE account='%u'", account.Unbox());
banList_IDHash.Delete(account,ban);
banList_IPRList.Delete(ban);
delete ban;
return true;
}
示例12: to_issuer
bool
to_issuer (AccountID& issuer, std::string const& s)
{
if (s.size () == (160 / 4))
{
issuer.SetHex (s);
return true;
}
auto const account =
parseBase58<AccountID>(s);
if (! account)
return false;
issuer = *account;
return true;
}
示例13: GenerateMsgHead
//新增加帐号
void CAccountDBAddHandler::AddAccount(unsigned uiSessionFd, const AccountID& stAccountID, int iWorldID, const std::string& strPasswd)
{
static GameProtocolMsg stMsg;
//生成消息头
GenerateMsgHead(&stMsg, uiSessionFd, MSGID_ACCOUNTDB_ADDACCOUNT_REQUEST, GetAccountHash(stAccountID.straccount()));
//AccountDB插入新帐号的请求
AccountDB_AddAccount_Request* pstReq = stMsg.mutable_m_stmsgbody()->mutable_m_staccountdb_addaccount_request();
pstReq->mutable_staccountid()->CopyFrom(stAccountID);
pstReq->set_iworldid(iWorldID);
//加密密码
char szEncryptPasswd[256] = {0};
int iEncryptBuffLen = sizeof(szEncryptPasswd);
int iRet = CPasswordEncryptionUtility::DoPasswordEncryption(strPasswd.c_str(), strPasswd.size(), szEncryptPasswd, iEncryptBuffLen);
if(iRet)
{
TRACESVR("Failed to encrypt account password, account: %s, password: %s\n", stAccountID.straccount().c_str(), strPasswd.c_str());
return;
}
//设置密码为加密后的密码
pstReq->set_strpassword(szEncryptPasswd, iEncryptBuffLen);
//转发消息给AccountDBServer
if(EncodeAndSendCode(SSProtocolEngine, NULL, &stMsg, GAME_SERVER_ACCOUNTDB) != 0)
{
TRACESVR("Failed to send add account request to Account DB server\n");
return;
}
LOGDEBUG("Send add account request to Account DB server\n");
return;
}
示例14: Debug1
void CharCreationManager::HandleUploadMessage(MsgEntry* me, Client* client)
{
Debug1(LOG_NEWCHAR, me->clientnum,"New Character is being created");
psCharUploadMessage upload(me);
if(!upload.valid)
{
Debug2(LOG_NET,me->clientnum,"Received unparsable psUploadMessage from client %u.",me->clientnum);
return;
}
AccountID acctID = client->GetAccountID();
if(!acctID.IsValid())
{
Error2("Player tried to upload a character to unknown account %s.", ShowID(acctID));
psCharRejectedMessage reject(me->clientnum);
psserver->GetEventManager()->Broadcast(reject.msg, NetBase::BC_FINALPACKET);
psserver->RemovePlayer(me->clientnum,"Could not find your account.");
return;
}
// Check to see if the player already has 4 accounts;
csString query;
query.Format("SELECT id FROM characters WHERE account_id=%d", acctID.Unbox());
Result result(db->Select(query));
if(result.IsValid() && result.Count() >= CHARACTERS_ALLOWED)
{
psserver->RemovePlayer(me->clientnum,"At your character limit.");
return;
}
csString playerName = upload.name;
csString lastName = upload.lastname;
playerName = NormalizeCharacterName(playerName);
lastName = NormalizeCharacterName(lastName);
// Check banned names
if(psserver->GetCharManager()->IsBanned(playerName))
{
csString error;
error.Format("The name %s is banned", playerName.GetData());
psCharRejectedMessage reject(me->clientnum,
psCharRejectedMessage::RESERVED_NAME,
(char*)error.GetData());
reject.SendMessage();
return;
}
if(psserver->GetCharManager()->IsBanned(lastName))
{
csString error;
error.Format("The lastname %s is banned", lastName.GetData());
psCharRejectedMessage reject(me->clientnum,
psCharRejectedMessage::RESERVED_NAME,
(char*)error.GetData());
reject.SendMessage();
return;
}
Debug3(LOG_NEWCHAR, me->clientnum,"Got player firstname (%s) and lastname (%s)\n",playerName.GetData(), lastName.GetData());
///////////////////////////////////////////////////////////////
// Check to see if the player name is valid
///////////////////////////////////////////////////////////////
if(playerName.Length() == 0 || !FilterName(playerName))
{
psCharRejectedMessage reject(me->clientnum,
psCharRejectedMessage::NON_LEGAL_NAME,
"The name you specifed is not a legal player name.");
psserver->GetEventManager()->SendMessage(reject.msg);
return;
}
if(lastName.Length() != 0 && !FilterName(lastName))
{
psCharRejectedMessage reject(me->clientnum,
psCharRejectedMessage::NON_LEGAL_NAME,
"The name you specifed is not a legal lastname.");
psserver->GetEventManager()->SendMessage(reject.msg);
return;
}
Debug2(LOG_NEWCHAR, me->clientnum,"Checking player firstname '%s'..\n",playerName.GetData());
///////////////////////////////////////////////////////////////
// Check to see if the character name is unique in 'characters'.
///////////////////////////////////////////////////////////////
if(!IsUnique(playerName))
{
psCharRejectedMessage reject(me->clientnum,
psCharRejectedMessage::NON_UNIQUE_NAME,
"The firstname you specifed is not unique.");
psserver->GetEventManager()->SendMessage(reject.msg);
return;
//.........这里部分代码省略.........
示例15: PlayerHasFinishedTutorial
bool CharCreationManager::PlayerHasFinishedTutorial(AccountID acctID, uint32 tutorialsecid)
{
// if there are characters associated with this account that are outside the tutorial assume the tutorial was passed...
Result result(db->Select("SELECT id FROM characters WHERE account_id = %u AND loc_sector_id != %u", acctID.Unbox(), tutorialsecid));
if(result.IsValid() && result.Count())
{
return true;
}
return false;
}