2021-01-29 21:15:18 +00:00
|
|
|
#!/usr/bin/env python
|
2021-02-04 01:52:36 +00:00
|
|
|
from base64 import b85decode
|
2021-01-29 21:15:18 +00:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
import ujson as json
|
|
|
|
|
|
|
|
from onionrblocks import blockcreator
|
|
|
|
|
|
|
|
# This script creates a block without storing it. it is written to stdout
|
|
|
|
# It is used instead of in the main process to avoid GIL locking/slow down
|
|
|
|
|
|
|
|
metadata = json.loads(sys.argv[1])
|
|
|
|
block_type = sys.argv[2]
|
|
|
|
ttl = int(sys.argv[3])
|
|
|
|
|
2021-02-04 01:52:36 +00:00
|
|
|
data = b85decode(sys.stdin.read())
|
2021-01-29 21:15:18 +00:00
|
|
|
|
|
|
|
with os.fdopen(sys.stdout.fileno(), 'wb') as stdout:
|
|
|
|
bl = blockcreator.create_anonvdf_block(data, block_type, ttl, **metadata)
|
|
|
|
try:
|
|
|
|
stdout.write(bl.id + bl.get_packed())
|
|
|
|
except BrokenPipeError:
|
|
|
|
pass
|