Add profile whitelist (#160)

* Add whitelisted field to profile table

* Fix adding whitelisted field to profile, itest passes now
This commit is contained in:
Jonathan Zernik 2020-07-28 02:05:33 -07:00 committed by GitHub
parent b207469046
commit 06e642b19c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 4 deletions

View file

@ -29,5 +29,6 @@ CREATE TABLE IF NOT EXISTS profile (
private_key bytea,
address VARCHAR(35) UNIQUE NOT NULL, -- Maximum length of a bitcoin address is 35.
sharing BOOLEAN NOT NULL,
following BOOLEAN NOT NULL
following BOOLEAN NOT NULL,
whitelisted BOOLEAN NOT NULL
);

View file

@ -153,6 +153,9 @@ message SqueakProfile {
/// Following
bool following = 6;
/// Whitelisted
bool whitelisted = 7;
}
message MakeSqueakRequest {

View file

@ -184,6 +184,7 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
address=squeak_profile.address,
sharing=squeak_profile.sharing,
following=squeak_profile.following,
whitelisted=squeak_profile.whitelisted,
)
def serve(self):

View file

@ -128,6 +128,7 @@ class SqueakNode:
address=str(address),
sharing=False,
following=False,
whitelisted=False,
)
return self.postgres_db.insert_profile(squeak_profile)
@ -142,6 +143,7 @@ class SqueakNode:
address=squeak_address,
sharing=False,
following=False,
whitelisted=False,
)
return self.postgres_db.insert_profile(squeak_profile)

View file

@ -189,8 +189,8 @@ class PostgresDb:
def insert_profile(self, squeak_profile):
""" Insert a new squeak profile. """
sql = """
INSERT INTO profile(profile_name, private_key, address, sharing, following)
VALUES(%s, %s, %s, %s, %s)
INSERT INTO profile(profile_name, private_key, address, sharing, following, whitelisted)
VALUES(%s, %s, %s, %s, %s, %s)
RETURNING profile_id;
"""
with self.get_cursor() as curs:
@ -203,6 +203,7 @@ class PostgresDb:
squeak_profile.address,
squeak_profile.sharing,
squeak_profile.following,
squeak_profile.whitelisted,
),
)
# get the new profile id back
@ -325,6 +326,7 @@ class PostgresDb:
address=row["address"],
sharing=row["sharing"],
following=row["following"],
whitelisted=row["whitelisted"],
)
def _parse_squeak_entry_with_profile(self, row):

View file

@ -2,5 +2,5 @@ from collections import namedtuple
SqueakProfile = namedtuple(
"SqueakProfile",
"profile_id, profile_name, private_key, address, sharing, following",
"profile_id, profile_name, private_key, address, sharing, following, whitelisted",
)