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

Commit a57a00f

Browse files
committed
Add pinned flag to contract
1 parent 681ce34 commit a57a00f

File tree

4 files changed

+57
-44
lines changed

4 files changed

+57
-44
lines changed

api/restapi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ def parse_listings(listings):
233233
"nsfw": l.nsfw,
234234
"origin": str(CountryCode.Name(l.origin)),
235235
"ships_to": [],
236-
"last_modified": l.last_modified
236+
"last_modified": l.last_modified,
237+
"pinned": l.pinned
237238
}
238239
if l.contract_type != 0:
239240
listing_json["contract_type"] = str(objects.Listings.ContractType.Name(l.contract_type))
@@ -549,6 +550,7 @@ def set_contract(self, request):
549550
else:
550551
c = Contract(self.db, testnet=self.protocol.testnet)
551552
c.create(
553+
str_to_bool(request.args["pinned"][0]),
552554
str(request.args["expiration_date"][0]),
553555
request.args["metadata_category"][0],
554556
request.args["title"][0].decode("utf8"),

market/contracts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def __init__(self, database, contract=None, hash_value=None, testnet=False):
9494
self.outpoints = []
9595

9696
def create(self,
97+
pinned,
9798
expiration_date,
9899
metadata_category,
99100
title,
@@ -150,7 +151,8 @@ def create(self,
150151
"version": "1",
151152
"category": metadata_category.lower(),
152153
"category_sub": "fixed price",
153-
"last_modified": int(time.time())
154+
"last_modified": int(time.time()),
155+
"pinned": pinned
154156
},
155157
"id": {
156158
"guid": self.keychain.guid.encode("hex"),
@@ -1065,6 +1067,7 @@ def save(self):
10651067
elif self.contract["vendor_offer"]["listing"]["metadata"]["category"].lower() == "service":
10661068
data.contract_type = listings.SERVICE
10671069
data.last_modified = int(time.time())
1070+
data.pinned = self.contract["vendor_offer"]["listing"]["metadata"]["pinned"]
10681071

10691072
# save the mapping of the contract file path and contract hash in the database
10701073
self.db.filemap.insert(data.contract_hash.encode("hex"), file_path[len(DATA_FOLDER):])

protos/objects.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ message Listings {
123123
string handle = 11;
124124
ContractType contract_type = 12;
125125
uint64 last_modified = 13;
126+
bool pinned = 14;
126127
}
127128

128129
enum ContractType {

0 commit comments

Comments
 (0)