Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/0.20' into 0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
lostystyg committed Mar 18, 2022
2 parents 287521d + d6f8b68 commit 283952c
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 35 deletions.
2 changes: 1 addition & 1 deletion contrib/seeds/nodes_main.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
64.235.45.119
216.108.231.40
135.181.196.243
65.21.56.203
Expand All @@ -9,3 +8,4 @@
46.175.123.77
178.217.155.169
178.217.155.170
93.100.117.108
35 changes: 23 additions & 12 deletions doc/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ This software allows you to participate in the work of the blockchain network -

To start a node independently, you need basic skills of working with the operating system, understanding the principle of the blockchain network. A deeper level of personal computer proficiency is welcome.

## Prerequisities
## Minimum System Requirements
Below are the minimum system requirements to run a PocketNet node to use as a wallet, for coin staking to earn PKOIN, and to use as a local node on your home network. A node with these requirements may need to be upgraded within the next 1 - 2 years.

PocketnetCore is distributed in two ways: binary installer and build from source code.
- 2 core x86-64 CPU
- 4GB RAM
- 100 GB harddrive
- 10 Mbps internet connection

Minimum system requirements:
- 4 core CPU
- 20GB RAM
- 25GB free disk space
- 10Mbps internet connection
## Recommended System Requirements
The below system requirements are recommended for a node which will act as a public node to service the Bastyon front end, in addition to wallet, and coin staking capabilities. The recommended requirements should provide enough headroom to support the PocketNet network for at least 2 years into the future.

- 4 core x86-64 CPU
- 16 GB RAM
- 500 GB SSD Harddrive
- 100 Mbps internet connection
- Publicly accessible IP address and ports (see Network Setup below)

## Docker installation
In order to run this container you'll need docker installed.

* [Windows](https://docs.docker.com/windows/started)
Expand All @@ -36,9 +44,10 @@ In order to run this container you'll need docker installed.
```shell
$ docker run -d \
--name=pocketnet.core \
--log-driver local
--log-opt max-size=10m
--log-opt max-file=3
--ulimit nofile=65536:65536 \
--log-driver local \
--log-opt max-size=10m \
--log-opt max-file=3 \
-p 37070:37070 \
-p 37071:37071 \
-p 38081:38081 \
Expand All @@ -47,7 +56,7 @@ $ docker run -d \
pocketnetteam/pocketnet.core:latest
```

### But we recommend using `docker-compose.yml` to configure the node:
### We recommend using `docker-compose.yml` to configure the node:
```yml
version: '3.7'
services:
Expand All @@ -56,6 +65,7 @@ services:
image: pocketnetteam/pocketnet.core:latest
restart: on-failure
stop_grace_period: 1m30s
# Increasing the number of available file descriptors
ulimits:
nofile:
soft: "65536"
Expand All @@ -81,7 +91,8 @@ services:
### Access to node API over CLI tool
```shell
docker exec -it pocketnet.core pocketcoin-cli help
$ docker exec -it pocketnet.core pocketcoin-cli help
$ docker exec -it pocketnet.core /bin/sh
```

## Help
Expand Down
4 changes: 2 additions & 2 deletions src/chainparamsseeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly.
*/
static SeedSpec6 pnSeed6_main[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x40,0xeb,0x2d,0x77}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd8,0x6c,0xe7,0x28}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x87,0xb5,0xc4,0xf3}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x41,0x15,0x38,0xcb}, 37070},
Expand All @@ -18,7 +17,8 @@ static SeedSpec6 pnSeed6_main[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0xaf,0x7a,0xf3}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x2e,0xaf,0x7b,0x4d}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0xd9,0x9b,0xa9}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0xd9,0x9b,0xaa}, 37070}
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xb2,0xd9,0x9b,0xaa}, 37070},
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x5d,0x64,0x75,0x6c}, 37070}
};

static SeedSpec6 pnSeed6_test[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/pocketdb/consensus/social/User.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ namespace PocketConsensus
{ 0, -1, [](int height) { return make_shared<UserConsensus>(height); }},
{ 1180000, 0, [](int height) { return make_shared<UserConsensus_checkpoint_1180000>(height); }},
{ 1381841, 162000, [](int height) { return make_shared<UserConsensus_checkpoint_1381841>(height); }},
{ 1629000, 650000, [](int height) { return make_shared<UserConsensus_checkpoint_login_limitation>(height); }}, // ~ 03/25/2022
{ 1647000, 650000, [](int height) { return make_shared<UserConsensus_checkpoint_login_limitation>(height); }}, // ~ 03/25/2022
};
public:
shared_ptr<UserConsensus> Instance(int height)
Expand Down
69 changes: 68 additions & 1 deletion src/pocketdb/repositories/web/SearchRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace PocketDb
return ids;
}

vector<int64_t> SearchRepository::SearchUsers(const SearchRequest& request)
vector<int64_t> SearchRepository::SearchUsersOld(const SearchRequest& request)
{
auto func = __func__;
vector<int64_t> result;
Expand Down Expand Up @@ -164,6 +164,73 @@ namespace PocketDb
return result;
}

vector<int64_t> SearchRepository::SearchUsers(const string& keyword)
{
auto func = __func__;
vector<int64_t> result;

string _keyword = "\"" + keyword + "\"" + " OR " + keyword + "*";

string sql = R"sql(
select names.* from (
select
fm.ContentId
, ROW_NUMBER() OVER ( ORDER BY RANK, length(f.Value) ) as ROWNUMBER
, RANK as RNK
, r.Value as Rating
from web.Content f
join web.ContentMap fm on fm.ROWID = f.ROWID
left join Ratings r on r.Id = fm.ContentId and r.Last = 1 and r.Type = 0
where fm.FieldType in (?)
and f.Value match ?
limit ?
) names
union
select about.* from (
select
fm.ContentId
, ROW_NUMBER() OVER ( ORDER BY r.Value DESC) as ROWNUMBER
, RANK as RNK
, r.Value as Rating
from web.Content f
join web.ContentMap fm on fm.ROWID = f.ROWID
left join Ratings r on r.Id = fm.ContentId and r.Last = 1 and r.Type = 0
where fm.FieldType in (?)
and f.Value match ?
limit ?
) about
order by ROWNUMBER, RNK, Rating desc
)sql";

TryTransactionStep(__func__, [&]()
{
int i = 1;
auto stmt = SetupSqlStatement(sql);

TryBindStatementInt(stmt, i++, (int)ContentFieldType::ContentFieldType_AccountUserName);
TryBindStatementText(stmt, i++, _keyword);
TryBindStatementInt(stmt, i++, 10);

TryBindStatementInt(stmt, i++, (int)ContentFieldType::ContentFieldType_AccountUserAbout);
TryBindStatementText(stmt, i++, _keyword);
TryBindStatementInt(stmt, i++, 10);

while (sqlite3_step(*stmt) == SQLITE_ROW)
{
if (auto[ok, value] = TryGetColumnInt64(*stmt, 0); ok)
if (find(result.begin(), result.end(), value) == result.end())
result.push_back(value);
}

FinalizeSqlStatement(*stmt);
});

return result;
}

UniValue SearchRepository::GetRecomendedAccountsBySubscriptions(const string& address, int cntOut)
{
auto func = __func__;
Expand Down
3 changes: 2 additions & 1 deletion src/pocketdb/repositories/web/SearchRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace PocketDb
UniValue SearchTags(const SearchRequest& request);
vector<int64_t> SearchIds(const SearchRequest& request);

vector<int64_t> SearchUsers(const SearchRequest& request);
vector<int64_t> SearchUsersOld(const SearchRequest& request);
vector<int64_t> SearchUsers(const string& keyword);

UniValue GetRecomendedAccountsBySubscriptions(const string& address, int cntOut = 10);
UniValue GetRecomendedAccountsByScoresOnSimilarAccounts(const string& address, const vector<int>& contentTypes, int nHeight, int depth = 1000, int cntOut = 10);
Expand Down
2 changes: 1 addition & 1 deletion src/pocketdb/repositories/web/WebRpcRepository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ namespace PocketDb
if (auto[ok, value] = TryGetColumnInt64(*stmt, 8); ok) result.pushKV("comment_spent", value);
if (auto[ok, value] = TryGetColumnInt64(*stmt, 9); ok) result.pushKV("score_spent", value);
if (auto[ok, value] = TryGetColumnInt64(*stmt, 10); ok) result.pushKV("comment_score_spent", value);
if (auto[ok, value] = TryGetColumnInt64(*stmt, 12); ok) result.pushKV("complain_spent", value);
if (auto[ok, value] = TryGetColumnInt64(*stmt, 11); ok) result.pushKV("complain_spent", value);
}

FinalizeSqlStatement(*stmt);
Expand Down
2 changes: 1 addition & 1 deletion src/pocketdb/web/PocketTransactionRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace PocketWeb::PocketWebRpc

// TODO (team): TEMPORARY
// Temporary check for UserConsensus_checkpoint_login_limitation checkpoint
// Remove this after 1629000 in main net
// Remove this after 1647000 in main net
if (*ptx->GetType() == ACCOUNT_USER)
{
std::shared_ptr<PocketConsensus::UserConsensus> accountUserConsensus = std::make_shared<PocketConsensus::UserConsensus_checkpoint_login_limitation>(ChainActive().Height());
Expand Down
23 changes: 9 additions & 14 deletions src/pocketdb/web/SearchRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace PocketWeb::PocketWebRpc
};

// Search
auto ids = request.DbConnection()->SearchRepoInst->SearchUsers(searchRequest);
auto ids = request.DbConnection()->SearchRepoInst->SearchUsersOld(searchRequest);

// Get accounts data
auto accounts = request.DbConnection()->WebRpcRepoInst->GetAccountProfiles(ids, true);
Expand Down Expand Up @@ -193,22 +193,17 @@ namespace PocketWeb::PocketWebRpc
{
RPCTypeCheck(request.params, {UniValue::VSTR});

SearchRequest searchRequest;
UniValue result(UniValue::VARR);

searchRequest.Keyword = HtmlUtils::UrlDecode(request.params[0].get_str());
searchRequest.FieldTypes = { ContentFieldType::ContentFieldType_AccountUserName };
// ContentFieldType::ContentFieldType_AccountUserAbout, ContentFieldType::ContentFieldType_AccountUserUrl
searchRequest.OrderByRank = true;
string keyword = HtmlUtils::UrlDecode(request.params[0].get_str());
if (keyword.size() <= 1)
return result;

auto ids = request.DbConnection()->SearchRepoInst->SearchUsers(searchRequest);
auto ids = request.DbConnection()->SearchRepoInst->SearchUsers(keyword);
auto usersProfiles = request.DbConnection()->WebRpcRepoInst->GetAccountProfiles(ids);

UniValue result(UniValue::VARR);
for (auto &profile : usersProfiles)
{
// profile.second.pushKV("searchResult", users[profile.first]);
result.push_back(profile.second);
}

for (auto& id : ids)
result.push_back(usersProfiles[id]);

return result;
},
Expand Down
2 changes: 1 addition & 1 deletion src/websocket/notifyprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void NotifyBlockProcessor::Process(std::pair<CBlock, CBlockIndex*> entry)
PrepareWSMessage(messages, "transaction", addr.first, txid, txtime, cTrFields);

// Event for new PocketNET transaction
if (optype == "share" || optype == "video" || "article")
if (optype == "share" || optype == "video" || optype == "article")
{
auto response = PocketDb::NotifierRepoInst.GetPostInfo(txid);
if (response.exists("hash") && response.exists("rootHash") && response["hash"].get_str() != response["rootHash"].get_str())
Expand Down

0 comments on commit 283952c

Please sign in to comment.