mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-14 12:43:24 +02:00
Add profile whitelist (#160)
* Add whitelisted field to profile table * Fix adding whitelisted field to profile, itest passes now
This commit is contained in:
parent
b207469046
commit
06e642b19c
6 changed files with 13 additions and 4 deletions
3
init.sql
3
init.sql
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@ message SqueakProfile {
|
|||
|
||||
/// Following
|
||||
bool following = 6;
|
||||
|
||||
/// Whitelisted
|
||||
bool whitelisted = 7;
|
||||
}
|
||||
|
||||
message MakeSqueakRequest {
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue