2020-06-17 11:58:22 +00:00
|
|
|
import logging
|
2020-06-17 11:53:10 +00:00
|
|
|
|
|
|
|
from pack import StickerPack, ipfsBinToText
|
|
|
|
|
2020-06-17 11:58:22 +00:00
|
|
|
LOG = logging.getLogger('root')
|
|
|
|
|
2020-06-17 13:01:44 +00:00
|
|
|
def pinAllPacks(ipfs, contract):
|
2020-07-27 11:51:24 +00:00
|
|
|
LOG.debug('Querying contract for pack hashes...')
|
2020-06-17 11:53:10 +00:00
|
|
|
# Get hashes of sticker packs the contract knows about
|
2020-06-17 13:01:44 +00:00
|
|
|
pack_hashes = contract.getAllPackHashes()
|
2020-06-17 11:53:10 +00:00
|
|
|
|
2020-07-27 11:51:24 +00:00
|
|
|
LOG.debug('Converting pack hashes...')
|
2020-06-17 11:53:10 +00:00
|
|
|
# Covert hashes into covert into more easily usable StickerPacks
|
|
|
|
packs = [StickerPack(ipfsBinToText(h)) for h in pack_hashes]
|
|
|
|
|
|
|
|
# Iterate over packs and make sure they are all pinned
|
|
|
|
for pack in packs:
|
2020-06-17 15:18:16 +00:00
|
|
|
pack.pin(ipfs)
|