Skip to content

Commit

Permalink
Add custom grpc msg sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptosharks131 committed Jul 11, 2023
1 parent 6fe6bb0 commit 35b26fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gui/af.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def main(channels):
lowliq_limit = int(LocalSettings.objects.filter(key='AF-LowLiqLimit').get().value)
else:
LocalSettings(key='AF-LowLiqLimit', value='5').save()
lowliq_limit = 15
lowliq_limit = 5
if LocalSettings.objects.filter(key='AF-ExcessLimit').exists():
excess_limit = int(LocalSettings.objects.filter(key='AF-ExcessLimit').get().value)
else:
LocalSettings(key='AF-ExcessLimit', value='95').save()
excess_limit = 90
excess_limit = 95
if lowliq_limit >= excess_limit:
print('Invalid thresholds detected, using defaults...')
lowliq_limit = 5
Expand Down
4 changes: 2 additions & 2 deletions gui/lnd_deps/lnd_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def metadata_callback(context, callback):
return creds

def lnd_connect():
return grpc.secure_channel(settings.LND_RPC_SERVER, creds(), options=[('grpc.max_send_message_length', 29999999), ('grpc.max_receive_message_length', 29999999),])
return grpc.secure_channel(settings.LND_RPC_SERVER, creds(), options=[('grpc.max_send_message_length', int(settings.LND_MAX_MESSAGE)*1000000), ('grpc.max_receive_message_length', int(settings.LND_MAX_MESSAGE)*1000000),])

def async_lnd_connect():
return grpc.aio.secure_channel(settings.LND_RPC_SERVER, creds(), options=[('grpc.max_send_message_length', 29999999), ('grpc.max_receive_message_length', 29999999),])
return grpc.aio.secure_channel(settings.LND_RPC_SERVER, creds(), options=[('grpc.max_send_message_length', int(settings.LND_MAX_MESSAGE)*1000000), ('grpc.max_receive_message_length', int(settings.LND_MAX_MESSAGE)*1000000),])

def main():
pass
Expand Down
9 changes: 6 additions & 3 deletions initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
BASE_DIR = Path(__file__).resolve().parent

def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, whitenoise, debug, csrftrusted, nologinrequired):
def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, lnd_max_message, whitenoise, debug, csrftrusted, nologinrequired):
#Generate a unique secret to be used for your django site
secret = secrets.token_urlsafe(64)
if whitenoise:
Expand Down Expand Up @@ -61,6 +61,7 @@ def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path,
LND_DATABASE_PATH = '%s'
LND_NETWORK = '%s'
LND_RPC_SERVER = '%s'
LND_MAX_MESSAGE = '%s'
LOGIN_REQUIRED = %s
# Application definition
Expand Down Expand Up @@ -170,7 +171,7 @@ def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path,
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'gui/static/')
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
''' % (secret, debug, node_ip, csrf, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, not nologinrequired, wnl, api_login)
''' % (secret, debug, node_ip, csrf, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, lnd_max_message, not nologinrequired, wnl, api_login)
try:
f = open("lndg/settings.py", "x")
f.close()
Expand Down Expand Up @@ -261,6 +262,7 @@ def main():
parser.add_argument('-dir', '--lnddir',help = 'LND Directory for tls cert and admin macaroon paths', default=None)
parser.add_argument('-net', '--network', help = 'Network LND will run over', default='mainnet')
parser.add_argument('-server', '--rpcserver', help = 'Server address to use for rpc communications with LND', default='localhost:10009')
parser.add_argument('-maxmsg', '--maxmessage', help = 'Maximum message size for grpc communications (MB)', default='35')
parser.add_argument('-sd', '--supervisord', help = 'Setup supervisord to run jobs/rebalancer background processes', action='store_true')
parser.add_argument('-sdu', '--sduser', help = 'Configure supervisord with a non-root user', default='root')
parser.add_argument('-wn', '--whitenoise', help = 'Add whitenoise middleware (docker requirement for static files)', action='store_true')
Expand All @@ -278,6 +280,7 @@ def main():
lnd_dir_path = args.lnddir if args.lnddir else '~/.lnd'
lnd_network = args.network
lnd_rpc_server = args.rpcserver
lnd_max_message = args.maxmessage
setup_supervisord = args.supervisord
sduser = args.sduser
whitenoise = args.whitenoise
Expand All @@ -293,7 +296,7 @@ def main():
if docker:
setup_supervisord = True
whitenoise = True
write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, whitenoise, debug, csrftrusted, nologinrequired)
write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, lnd_network, lnd_rpc_server, lnd_max_message, whitenoise, debug, csrftrusted, nologinrequired)
if setup_supervisord:
print('Supervisord setup requested...')
write_supervisord_settings(sduser)
Expand Down

0 comments on commit 35b26fd

Please sign in to comment.