Skip to content

Commit 16af938

Browse files
committed
Filecoin: Use 64-bit values
1 parent 332e7f4 commit 16af938

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Filecoin/Transaction.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
// file LICENSE at the root of the source code distribution tree.
66

77
#include "Transaction.h"
8+
#include "../BinaryCoding.h"
89

910
using namespace TW;
1011
using namespace TW::Filecoin;
1112

12-
// encode_varuint encodes a 256-bit number into a big endian encoding, omitting leading zeros.
13-
static Data encode_varuint(const uint256_t& value) {
13+
// encode_varuint encodes a 64-bit number into a big endian encoding, omitting leading zeros.
14+
static Data encode_varuint(uint64_t value) {
1415
Data data;
15-
encode256BE(data, value, 256);
16+
encode64BE(value, data);
1617
int i = 0;
1718
for (i = 0; i < (int)data.size(); ++i)
1819
if (data[i] != 0)

src/Filecoin/Transaction.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "Address.h"
1010
#include "../Cbor.h"
11-
#include "../uint256.h"
1211

1312
namespace TW::Filecoin {
1413

@@ -21,25 +20,25 @@ class Transaction {
2120
// Transaction nonce
2221
uint64_t nonce;
2322
// Transaction value
24-
uint256_t value;
23+
uint64_t value;
2524
// Miner fee
26-
uint256_t gas_price;
27-
uint256_t gas_limit;
25+
uint64_t gas_price;
26+
uint64_t gas_limit;
2827
// Transaction type; 0 for simple transfers
2928
uint64_t method;
3029
// Transaction data; empty for simple transfers
3130
Data params;
3231
// secp256k1 signature data (excluding type byte)
3332
Data signature;
3433

35-
Transaction(Address to, Address from, uint64_t nonce, uint256_t value, uint256_t gprice,
36-
uint256_t glimit)
34+
Transaction(Address to, Address from, uint64_t nonce, uint64_t value, uint64_t gprice,
35+
uint64_t glimit)
3736
: to(std::move(to))
3837
, from(std::move(from))
3938
, nonce(nonce)
40-
, value(std::move(value))
41-
, gas_price(std::move(gprice))
42-
, gas_limit(std::move(glimit))
39+
, value(value)
40+
, gas_price(gprice)
41+
, gas_limit(glimit)
4342
, method(0) {}
4443

4544
public:

0 commit comments

Comments
 (0)