Updated for python3 and use pyZcash packaging
This commit is contained in:
parent
303a8a80bc
commit
7cea8a4533
|
@ -1,4 +1,4 @@
|
|||
FROM python:2
|
||||
FROM python:3
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
WORKDIR /app
|
||||
|
@ -12,9 +12,7 @@ RUN useradd -d /home/zfaucet -s /bin/bash zfaucet \
|
|||
&& chown zfaucet /app/faucet/migrations \
|
||||
&& chown zfaucet /home/zcashd/zfaucet/faucet/static
|
||||
|
||||
RUN mkdir -p /app/lib/pyZcash \
|
||||
&& git clone https://github.com/zcash-hackworks/pyZcash.git /app/lib/pyZcash/
|
||||
|
||||
RUN chown -R zfaucet:zfaucet /app
|
||||
USER zfaucet
|
||||
ENTRYPOINT ["docker/zfaucet/entrypoint.sh"]
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
nginx:
|
||||
build:
|
||||
context: docker/nginx
|
||||
zfaucet:
|
||||
image: python:2
|
||||
volumes:
|
||||
- .:/app
|
||||
entrypoint: bash -c "sleep infinity"
|
||||
build: .
|
|
@ -12,9 +12,9 @@ services:
|
|||
nginx:
|
||||
image: nginx
|
||||
ports:
|
||||
- "8080:80"
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./docker/nginx/zfaucet.conf:/etc/nginx/conf.d/default.conf
|
||||
- static_volume:/usr/share/nginx/html/static
|
||||
depends_on:
|
||||
- zfaucet
|
||||
|
|
|
@ -16,6 +16,7 @@ server {
|
|||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
resolver 127.0.0.11 ipv6=off;
|
||||
set $upstream http://zfaucet:8000;
|
||||
|
||||
location / {
|
||||
|
|
|
@ -5,6 +5,7 @@ set -e
|
|||
python manage.py makemigrations
|
||||
python manage.py migrate
|
||||
python manage.py collectstatic --no-input
|
||||
python manage.py check_zcashd --wait 20
|
||||
python manage.py check_zcashd --wait 120
|
||||
python manage.py healthcheck
|
||||
gunicorn --bind=0.0.0.0:8000 --workers=2 zfaucet.wsgi
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ def index(request):
|
|||
hc = HealthCheck.objects.latest('timestamp')
|
||||
t_balance = hc.t_balance
|
||||
z_balance = hc.z_balance
|
||||
print "T balance", t_balance
|
||||
print " z balance", z_balance
|
||||
print('T balance'.format(t_balance))
|
||||
print('z balance"'.format(z_balance))
|
||||
balance = {'transparent': t_balance, 'private': z_balance}
|
||||
difficulty = hc.difficulty
|
||||
height = hc.height
|
||||
|
@ -47,8 +47,8 @@ def index(request):
|
|||
ip = request.META.get('HTTP_X_REAL_IP')
|
||||
ip = get_client_ip(request)
|
||||
address = request.POST.get('address', '')
|
||||
print "IP: ", ip
|
||||
print "address: ", address
|
||||
print('client IP: {}'.format(ip))
|
||||
print('client address: {}'.format(address))
|
||||
try:
|
||||
last_payout = Drip.objects.filter(Q(ip=ip) | Q(address=address)).order_by('-timestamp')[0]
|
||||
now = datetime.utcnow().replace(tzinfo=timezone.get_current_timezone())
|
||||
|
@ -78,17 +78,17 @@ def index(request):
|
|||
return render(request, 'faucet/faucet.html', {'version':version,'balance':balance,'difficulty':difficulty,'height':height, 'payouts':payouts, 'flash':True, 'message':msg})
|
||||
# Sapling address
|
||||
elif len(address) == len('ztestsapling1603ydy9hg79lv5sv9pm5hn95cngfv4qpd6y54a8wkyejn72jl30a4pfhw8u00p93mu4nj6qxsqg'):
|
||||
print 'Sapling addr'
|
||||
print('Received a Sapling address')
|
||||
# sender = 'ztestsapling1603ydy9hg79lv5sv9pm5hn95cngfv4qpd6y54a8wkyejn72jl30a4pfhw8u00p93mu4nj6qxsqg'
|
||||
zaddrs = zd.z_listaddresses()
|
||||
sender = zaddrs[1]
|
||||
msg = 'Thanks for using zfaucet!'
|
||||
opid = zd.z_sendmany(sender, address, 1.0, msg)
|
||||
print "OPID", opid
|
||||
print('OPID: {}'.format(opid))
|
||||
if opid != None and 'opid' in opid:
|
||||
resp = zd.z_getoperationstatus(opid)
|
||||
print "Operation status response:", resp
|
||||
print "operation status: ", resp[0]['status']
|
||||
print('Operation status response: {}'.format(resp))
|
||||
print('operation status: {}'.format(resp[0]['status']))
|
||||
#why is it not working when it's executing?
|
||||
if resp[0]['status'] == 'executing':
|
||||
msg = "Sent! You should receive your Sapling funds shortly."
|
||||
|
@ -99,16 +99,16 @@ def index(request):
|
|||
# Sprout
|
||||
elif len(address) == len('ztSwdDwPhpUZ447YU1BqjxrvutHfu2AyENwUohhTMhnWHreAEHTELhRLvqkARmCSudW1GAcrg58TVaqT7oTH1ohFA7k7V11'):
|
||||
# sender = 'ztSwdDwPhpUZ447YU1BqjxrvutHfu2AyENwUohhTMhnWHreAEHTELhRLvqkARmCSudW1GAcrg58TVaqT7oTH1ohFA7k7V11'
|
||||
print 'Sprout'
|
||||
print('Received a Sprout address')
|
||||
zaddrs = zd.z_listaddresses()
|
||||
sender = zaddrs[0]
|
||||
msg = 'Thanks for using zfaucet!'
|
||||
opid = zd.z_sendmany(sender, address, 1.0, msg)
|
||||
print "OPID", opid
|
||||
print('OPID: {}'.format(opid))
|
||||
if opid != None and 'opid' in opid:
|
||||
resp = zd.z_getoperationstatus(opid)
|
||||
print "Operation status response:", resp
|
||||
print "operation status: ", resp[0]['status']
|
||||
print('Operation status response: {}'.format(resp))
|
||||
print('operation status: {}'.format(resp[0]['status']))
|
||||
#why is it not working when it's executing?
|
||||
if resp[0]['status'] == 'executing':
|
||||
msg = "Sent! You should receive your Sprout funds shortly."
|
||||
|
@ -118,7 +118,7 @@ def index(request):
|
|||
return render(request, 'faucet/faucet.html', {'version':version,'balance':balance,'difficulty':difficulty,'height':height, 'payouts':payouts, 'flash':True, 'message':msg})
|
||||
except:
|
||||
# TODO: Give better error if faucet is empty!
|
||||
print "IN ERROR"
|
||||
print('ERROR: unknow address format')
|
||||
msg = "Issue sending transaction. Is your address correct?"
|
||||
return render(request, 'faucet/faucet.html', {'version':version,'balance':balance,'difficulty':difficulty,'height':height, 'payouts':payouts, 'flash':True, 'message':msg})
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
django
|
||||
requests
|
||||
git+https://github.com/benzcash/pyZcash@ben/python3-and-packaging
|
||||
|
|
|
@ -20,8 +20,10 @@ class Command(BaseCommand):
|
|||
timer += 1
|
||||
try:
|
||||
zd.getNetworkHeight()
|
||||
height = zd.getNetworkHeight()
|
||||
assert type(height) is int
|
||||
return
|
||||
except requests.exceptions.ConnectionError as e: # This is the correct syntax
|
||||
except (requests.exceptions.ConnectionError,AssertionError):
|
||||
pass
|
||||
self.stdout.write('Waiting {:d}s, elapsed {:d}s'.format(wait, timer) )
|
||||
self.stderr.write('Unable to connect to zcash at: {} within {:d}s'.format(zd.network, wait))
|
||||
|
|
|
@ -22,7 +22,7 @@ ENVIRONMENT = os.getenv('DJANGO_ENVIRONMENT', 'prod')
|
|||
# ENVIRONMENT = os.getenv('DJANGO_ENVIRONMENT', 'dev')
|
||||
if ENVIRONMENT not in ['dev', 'stage', 'prod']:
|
||||
raise Exception('Unknown settings environment "%s"' % ENVIRONMENT)
|
||||
print 'settings environment is ' + ENVIRONMENT
|
||||
print('settings environment is {}'.format(ENVIRONMENT))
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
#if ENVIRONMENT == 'prod':
|
||||
|
|
Loading…
Reference in New Issue