Skip to content

Commit e1d8d1f

Browse files
authored
Buffer remove (#485)
* Remove Buffer from file common Signed-off-by: ortyomka <[email protected]> * Remove Buffer from cbor Signed-off-by: ortyomka <[email protected]> * Remove Buffer from storages Signed-off-by: ortyomka <[email protected]> * Remove Buffer from project Signed-off-by: ortyomka <[email protected]> * Update putUint64 Signed-off-by: ortyomka <[email protected]>
1 parent 7422233 commit e1d8d1f

File tree

230 files changed

+1123
-2051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+1123
-2051
lines changed

core/api/common_api.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
#include "api/utils.hpp"
1111
#include "api/version.hpp"
12-
#include "common/buffer.hpp"
12+
#include "common/bytes.hpp"
1313
#include "primitives/jwt/jwt.hpp"
1414

1515
namespace fc::api {
16-
using common::Buffer;
1716
using libp2p::peer::PeerInfo;
1817
using primitives::jwt::Permission;
1918
namespace jwt = primitives::jwt;
@@ -25,7 +24,7 @@ namespace fc::api {
2524
*/
2625
API_METHOD(AuthNew,
2726
jwt::kAdminPermission,
28-
Buffer,
27+
Bytes,
2928
const std::vector<Permission> &)
3029
/**
3130
* Verify auth token

core/api/full_node/get_node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace fc::api {
4141
auto ha = starts_with(part, "@Ha:");
4242
auto h = starts_with(part, "@H:");
4343
if (a || hi || hu || ha || h) {
44-
raw = Buffer{s.raw()};
44+
raw = s.raw();
4545
OUTCOME_TRY(cid, common::getCidOf(raw));
4646
if (a) {
4747
OUTCOME_TRY(index, parseIndex(part.substr(3)));
@@ -68,7 +68,7 @@ namespace fc::api {
6868
OUTCOME_TRY(
6969
bytes,
7070
Hamt{ipld, cid, storage::hamt::kDefaultBitWidth}.get(key));
71-
raw = Buffer{bytes};
71+
raw = bytes;
7272
s = CborDecodeStream{raw};
7373
}
7474
parts = parts.subspan(1);
@@ -89,7 +89,7 @@ namespace fc::api {
8989
}
9090
}
9191
}
92-
raw = Buffer{s.raw()};
92+
raw = s.raw();
9393
OUTCOME_TRY(cid, common::getCidOf(raw));
9494
return IpldObject{std::move(cid), std::move(raw)};
9595
} catch (std::system_error &e) {

core/api/full_node/node_api.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ namespace fc::api {
236236

237237
struct IpldObject {
238238
CID cid;
239-
Buffer raw;
239+
Bytes raw;
240240
};
241241

242242
struct MiningBaseInfo {
@@ -267,7 +267,7 @@ namespace fc::api {
267267
Address owner;
268268
Address worker;
269269
std::vector<Address> control;
270-
Buffer peer_id;
270+
Bytes peer_id;
271271
std::vector<Multiaddress> multiaddrs;
272272
RegisteredPoStProof window_post_proof_type{RegisteredPoStProof::kUndefined};
273273
SectorSize sector_size{};
@@ -323,14 +323,14 @@ namespace fc::api {
323323
const TipsetKey &,
324324
DomainSeparationTag,
325325
ChainEpoch,
326-
const Buffer &)
326+
const Bytes &)
327327
API_METHOD(ChainGetRandomnessFromTickets,
328328
jwt::kReadPermission,
329329
Randomness,
330330
const TipsetKey &,
331331
DomainSeparationTag,
332332
ChainEpoch,
333-
const Buffer &)
333+
const Bytes &)
334334
API_METHOD(ChainGetTipSet,
335335
jwt::kReadPermission,
336336
TipsetCPtr,
@@ -342,7 +342,7 @@ namespace fc::api {
342342
const TipsetKey &)
343343
API_METHOD(ChainHead, jwt::kReadPermission, TipsetCPtr)
344344
API_METHOD(ChainNotify, jwt::kReadPermission, Chan<std::vector<HeadChange>>)
345-
API_METHOD(ChainReadObj, jwt::kReadPermission, Buffer, CID)
345+
API_METHOD(ChainReadObj, jwt::kReadPermission, Bytes, CID)
346346
API_METHOD(ChainSetHead, jwt::kAdminPermission, void, const TipsetKey &)
347347
API_METHOD(ChainTipSetWeight,
348348
jwt::kReadPermission,
@@ -526,7 +526,7 @@ namespace fc::api {
526526
TokenAmount,
527527
const Address &,
528528
const SignedVoucher &,
529-
const Buffer &,
529+
const Bytes &,
530530
const TokenAmount &)
531531

532532
/**
@@ -767,13 +767,13 @@ namespace fc::api {
767767
jwt::kSignPermission,
768768
Signature,
769769
const Address &,
770-
const Buffer &)
770+
const Bytes &)
771771
/** Verify signature by address (may be id or key address) */
772772
API_METHOD(WalletVerify,
773773
jwt::kReadPermission,
774774
bool,
775775
const Address &,
776-
const Buffer &,
776+
const Bytes &,
777777
const Signature &)
778778
};
779779

core/api/rpc/json.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ namespace fc::api {
371371
v = decodeBase64(j);
372372
}
373373

374-
DECODE(Buffer) {
375-
v = Buffer{decodeBase64(j)};
376-
}
377-
378374
ENCODE(CID) {
379375
OUTCOME_EXCEPT(str, v.toString());
380376
Value j{rapidjson::kObjectType};
@@ -585,7 +581,7 @@ namespace fc::api {
585581
boost::optional<PeerId> peer_id;
586582
Get(j, "PeerId", peer_id);
587583
if (peer_id) {
588-
v.peer_id = Buffer{peer_id->toVector()};
584+
v.peer_id = peer_id->toVector();
589585
} else {
590586
v.peer_id.clear();
591587
}

core/api/rpc/ws.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace fc::api {
138138
}
139139
}
140140

141-
std::queue<std::pair<Buffer, OkCb>> pending_writes;
141+
std::queue<std::pair<Bytes, OkCb>> pending_writes;
142142
bool writing{false};
143143
uint64_t next_channel{}, next_request{};
144144
websocket::stream<tcp::socket> socket;

core/api/rpc/wsc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace fc::api::rpc {
6464
uint64_t next_req{};
6565
std::map<uint64_t, ResultCb> result_queue;
6666
std::map<uint64_t, ChanCb> chans;
67-
std::queue<std::pair<uint64_t, Buffer>> write_queue;
67+
std::queue<std::pair<uint64_t, Bytes>> write_queue;
6868
bool writing{false};
6969

7070
template <typename M>

core/api/setup_common.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "api/utils.hpp"
1010
#include "api/version.hpp"
1111
#include "common/api_secret.hpp"
12-
#include "common/buffer.hpp"
1312
#include "common/logger.hpp"
1413
#include "common/span.hpp"
1514

@@ -24,10 +23,10 @@ namespace fc::api {
2423
auto verifier = ::jwt::verify()
2524
.with_type(static_cast<std::string>(kTokenType))
2625
.allow_algorithm(*secret_algorithm);
27-
api->AuthNew = [secret_algorithm](auto perms) -> outcome::result<Buffer> {
26+
api->AuthNew = [secret_algorithm](auto perms) -> outcome::result<Bytes> {
2827
OUTCOME_TRY(token, generateAuthToken(secret_algorithm, perms));
2928

30-
return Buffer{common::span::cbytes(token)};
29+
return Bytes(token.begin(), token.end());
3130
};
3231
api->AuthVerify =
3332
[verifier{std::move(verifier)},

core/blockchain/block_validator/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ add_library(block_validator
1111
target_link_libraries(block_validator
1212
bls_provider
1313
outcome
14-
buffer
1514
address
1615
clock
1716
interpreter

core/cbor_blake/ipld.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
#include <memory>
99

1010
#include "cbor_blake/cid.hpp"
11-
#include "common/buffer.hpp"
1211

1312
namespace fc {
1413
struct CbIpld {
1514
virtual ~CbIpld() = default;
16-
virtual bool get(const CbCid &key, Buffer *value) const = 0;
15+
virtual bool get(const CbCid &key, Bytes *value) const = 0;
1716
virtual void put(const CbCid &key, BytesIn value) = 0;
1817

1918
bool has(const CbCid &key) const {
2019
return get(key, nullptr);
2120
}
22-
bool get(const CbCid &key, Buffer &value) const {
21+
bool get(const CbCid &key, Bytes &value) const {
2322
return get(key, &value);
2423
}
2524
CbCid put(BytesIn cbor) {

core/cbor_blake/ipld_any.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace fc {
3030
}
3131
outcome::result<Value> get(const CID &key) const override {
3232
if (auto cid{asBlake(key)}) {
33-
Buffer value;
33+
Bytes value;
3434
if (ipld->get(*cid, value)) {
3535
return std::move(value);
3636
}
@@ -46,7 +46,7 @@ namespace fc {
4646

4747
explicit AnyAsCbIpld(IpldPtr ipld) : ipld{std::move(ipld)} {}
4848

49-
static bool get(const IpldPtr &ipld, const CbCid &key, Buffer *value) {
49+
static bool get(const IpldPtr &ipld, const CbCid &key, Bytes *value) {
5050
const CID cid{key};
5151
if (value) {
5252
if (auto r{ipld->get(cid)}) {
@@ -59,11 +59,11 @@ namespace fc {
5959
}
6060
return ipld->contains(cid).value();
6161
}
62-
bool get(const CbCid &key, Buffer *value) const override {
62+
bool get(const CbCid &key, Bytes *value) const override {
6363
return get(ipld, key, value);
6464
}
6565
void put(const CbCid &key, BytesIn value) override {
66-
ipld->set(CID{key}, Buffer{value}).value();
66+
ipld->set(CID{key}, copy(value)).value();
6767
}
6868
};
6969
} // namespace fc

0 commit comments

Comments
 (0)