Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 5863f88

Browse files
committed
Switch to proto3
1 parent c67f135 commit 5863f88

File tree

10 files changed

+341
-315
lines changed

10 files changed

+341
-315
lines changed

api/restapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ def update_profile(self, request):
396396
if "handle" in request.args:
397397
if blockchainid.validate(request.args["handle"][0], self.keychain.guid.encode("hex")):
398398
u.handle = request.args["handle"][0]
399-
p.db.set_temp_handle("")
399+
self.db.profile.set_temp_handle("")
400400
else:
401401
u.handle = ""
402-
p.db.set_temp_handle(request.args["handle"][0])
402+
self.db.profile.set_temp_handle(request.args["handle"][0])
403403
if "about" in request.args:
404404
u.about = request.args["about"][0]
405405
if "short_description" in request.args:

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ConfigParser import ConfigParser
1313
from urlparse import urlparse
1414

15-
PROTOCOL_VERSION = 13
15+
PROTOCOL_VERSION = 14
1616
CONFIG_FILE = join(os.getcwd(), 'ob.cfg')
1717

1818
# FIXME probably a better way to do this. This curretly checks two levels deep

market/contracts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def create(self,
226226
listing["shipping"]["est_delivery"]["domestic"] = est_delivery_domestic
227227
listing["shipping"]["est_delivery"][
228228
"international"] = est_delivery_international
229-
if profile.HasField("handle"):
229+
if profile.handle != "":
230230
self.contract["vendor_offer"]["listing"]["id"]["blockchain_id"] = profile.handle
231231
if images is not None:
232232
self.contract["vendor_offer"]["listing"]["item"]["image_hashes"] = []
@@ -316,7 +316,7 @@ def add_purchase_info(self,
316316
}
317317
}
318318
SelectParams("testnet" if self.testnet else "mainnet")
319-
if profile.HasField("handle"):
319+
if profile.handle != "":
320320
order_json["buyer_order"]["order"]["id"]["blockchain_id"] = profile.handle
321321
if self.contract["vendor_offer"]["listing"]["metadata"]["category"] == "physical good":
322322
order_json["buyer_order"]["order"]["shipping"] = {}

market/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def get_result(result):
269269
verify_key.verify(result[1][0], result[1][1])
270270
l = objects.Listings().ListingMetadata()
271271
l.ParseFromString(result[1][0])
272-
if l.HasField("thumbnail_hash"):
272+
if l.thumbnail_hash != "":
273273
if not os.path.isfile(DATA_FOLDER + 'cache/' + l.thumbnail_hash.encode("hex")):
274274
self.get_image(node_to_ask, l.thumbnail_hash)
275275
return l

protos/countries.proto

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/*
22
Get the protobuf compiler:
3-
sudo apt-get install protobuf-compiler
3+
You will need to manually compile protobuf v3.0.0-beta-2
4+
https://github.com/google/protobuf/releases/tag/v3.0.0-beta-2
45
56
Compile with:
67
cd path/to/protos/
78
protoc --python_out=./ countries.proto
89
*/
910

11+
syntax = "proto3";
12+
1013
enum CountryCode {
1114
NA = 0; // Use this for digital goods or services
1215
ALL = 1;

protos/countries.py

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/message.proto

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
/*
22
Get the protobuf compiler:
3-
sudo apt-get install protobuf-compiler
3+
You will need to manually compile protobuf v3.0.0-beta-2
4+
https://github.com/google/protobuf/releases/tag/v3.0.0-beta-2
45
56
Compile with:
67
cd path/to/protos/
78
protoc --python_out=./ message.proto
89
*/
910

11+
syntax = "proto3";
1012
import "objects.proto";
1113

1214
//This is the message structure for OpenBazaar messages going over the wire
1315
message Message {
14-
required bytes messageID = 1;
15-
required Node sender = 2;
16-
required Command command = 3;
17-
required uint32 protoVer = 4;
18-
repeated bytes arguments = 5;
19-
optional bool testnet = 6 [default = false];
20-
optional bytes signature = 7;
16+
bytes messageID = 1;
17+
Node sender = 2;
18+
Command command = 3;
19+
uint32 protoVer = 4;
20+
repeated bytes arguments = 5;
21+
bool testnet = 6;
22+
bytes signature = 7;
2123
}
2224

2325
//A list of commands accepted by nodes
2426
enum Command {
25-
PING = 1;
26-
STUN = 2;
27-
HOLE_PUNCH = 3;
28-
STORE = 4;
29-
DELETE = 5;
30-
INV = 6;
31-
VALUES = 7;
32-
BROADCAST = 8;
33-
MESSAGE = 9;
34-
FOLLOW = 10;
35-
UNFOLLOW = 11;
36-
ORDER = 12;
37-
ORDER_CONFIRMATION = 13;
38-
COMPLETE_ORDER = 14;
39-
FIND_NODE = 15;
40-
FIND_VALUE = 16;
41-
GET_CONTRACT = 17;
42-
GET_IMAGE = 18;
43-
GET_PROFILE = 19;
44-
GET_LISTINGS = 20;
45-
GET_USER_METADATA = 21;
46-
GET_CONTRACT_METADATA = 22;
47-
GET_FOLLOWING = 23;
48-
GET_FOLLOWERS = 24;
49-
GET_RATINGS = 25;
50-
DISPUTE_OPEN = 26;
51-
DISPUTE_CLOSE = 27;
52-
REFUND = 28;
27+
PING = 0;
28+
STUN = 1;
29+
HOLE_PUNCH = 2;
30+
STORE = 3;
31+
DELETE = 4;
32+
INV = 5;
33+
VALUES = 6;
34+
BROADCAST = 7;
35+
MESSAGE = 8;
36+
FOLLOW = 9;
37+
UNFOLLOW = 10;
38+
ORDER = 11;
39+
ORDER_CONFIRMATION = 12;
40+
COMPLETE_ORDER = 13;
41+
FIND_NODE = 14;
42+
FIND_VALUE = 15;
43+
GET_CONTRACT = 16;
44+
GET_IMAGE = 17;
45+
GET_PROFILE = 18;
46+
GET_LISTINGS = 19;
47+
GET_USER_METADATA = 20;
48+
GET_CONTRACT_METADATA = 21;
49+
GET_FOLLOWING = 22;
50+
GET_FOLLOWERS = 23;
51+
GET_RATINGS = 24;
52+
DISPUTE_OPEN = 25;
53+
DISPUTE_CLOSE = 26;
54+
REFUND = 27;
5355

5456
// Error responses
5557
BAD_REQUEST = 400;

0 commit comments

Comments
 (0)