Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate custom steemd instance to internal constructors #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions steem/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self,
steemd_instance=None):
self.steem = steemd_instance or shared_steemd_instance()
self.comments_only = comments_only
self.account = Account(account_name)
self.account = Account(account_name, steemd_instance=self.steem)
self.history = self.account.history_reverse(filter_by='comment')
self.seen_items = set()

Expand Down Expand Up @@ -79,7 +79,8 @@ def ensure_unique(post):

unique = filter(ensure_unique, hist2)

serialized = filter(bool, map(silent(Post), unique))
postmap = map(silent(lambda u: Post(u, self.steem)), unique)
serialized = filter(bool, postmap)

batch = take(limit, serialized)
return batch
Expand Down
20 changes: 10 additions & 10 deletions steem/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def legacyentry():
if not args.objects:
t = PrettyTable(["Key", "Value"])
t.align = "l"
blockchain = Blockchain(mode="head")
blockchain = Blockchain(mode="head", steemd_instance=steem)
info = blockchain.info()
median_price = steem.get_current_median_history_price()
steem_per_mvest = (
Expand All @@ -810,7 +810,7 @@ def legacyentry():
for obj in args.objects:
# Block
if re.match("^[0-9]*$", obj):
block = Block(obj)
block = Block(obj, steemd_instance=steem)
if block:
t = PrettyTable(["Key", "Value"])
t.align = "l"
Expand All @@ -825,7 +825,7 @@ def legacyentry():
# Account name
elif re.match("^[a-zA-Z0-9\-\._]{2,16}$", obj):
from math import log10
account = Account(obj)
account = Account(obj, steemd_instance=steem)
t = PrettyTable(["Key", "Value"])
t.align = "l"
for key in sorted(account):
Expand Down Expand Up @@ -867,7 +867,7 @@ def legacyentry():
print("Public Key not known" % obj)
# Post identifier
elif re.match(".*@.{3,16}/.*$", obj):
post = Post(obj)
post = Post(obj, steemd_instance=steem)
if post:
t = PrettyTable(["Key", "Value"])
t.align = "l"
Expand Down Expand Up @@ -961,7 +961,7 @@ def legacyentry():
print(t)

elif args.command == "upvote" or args.command == "downvote":
post = Post(args.post)
post = Post(args.post, steemd_instance=steem)
if args.command == "downvote":
weight = -float(args.weight)
else:
Expand Down Expand Up @@ -1009,7 +1009,7 @@ def legacyentry():
elif args.command == "balance":
if args.account and isinstance(args.account, list):
for account in args.account:
a = Account(account)
a = Account(account, steemd_instance=steem)

print("\n@%s" % a.name)
t = PrettyTable(["Account", "STEEM", "SBD", "VESTS"])
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def legacyentry():
print(t)

elif args.command == "permissions":
account = Account(args.account)
account = Account(args.account, steemd_instance=steem)
print_permissions(account)

elif args.command == "allow":
Expand Down Expand Up @@ -1132,7 +1132,7 @@ def legacyentry():
from steembase.account import PasswordKey
import getpass
password = getpass.getpass("Account Passphrase: ")
account = Account(args.account)
account = Account(args.account, steemd_instance=steem)
imported = False

if "owner" in args.roles:
Expand Down Expand Up @@ -1257,7 +1257,7 @@ def legacyentry():

profile = Profile(keys, values)

account = Account(args.account)
account = Account(args.account, steemd_instance=steem)
account["json_metadata"] = Profile(account["json_metadata"]
if account["json_metadata"] else {})
account["json_metadata"].update(profile)
Expand All @@ -1268,7 +1268,7 @@ def legacyentry():

elif args.command == "delprofile":
from .profile import Profile
account = Account(args.account)
account = Account(args.account, steemd_instance=steem)
account["json_metadata"] = Profile(account["json_metadata"])

for var in args.variable:
Expand Down
4 changes: 2 additions & 2 deletions steem/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def create_account(
remaining_fee = required_fee_steem - delegation_fee_steem
if remaining_fee > 0:
required_sp = remaining_fee * delegated_sp_fee_mult
required_fee_vests = Converter().sp_to_vests(required_sp) + 1
required_fee_vests = Converter(self.steemd).sp_to_vests(required_sp) + 1

s = {
'creator': creator,
Expand Down Expand Up @@ -898,7 +898,7 @@ def claim_reward_balance(self,
if none(
int(first(x.split(' ')))
for x in [reward_sbd, reward_steem, reward_vests]):
a = Account(account)
a = Account(account, steemd_instance=self.steemd)
reward_steem = a['reward_steem_balance']
reward_sbd = a['reward_sbd_balance']
reward_vests = a['reward_vesting_balance']
Expand Down
3 changes: 2 additions & 1 deletion steem/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def get_replies(self):
"""
post_author, post_permlink = resolve_identifier(self.identifier)
replies = self.steemd.get_content_replies(post_author, post_permlink)
return map(silent(Post), replies)
return map(silent(lambda r: Post(r, steemd_instance=self.steemd)),
replies)

@staticmethod
def get_all_replies(root_post=None, comments=list(), all_comments=list()):
Expand Down
2 changes: 1 addition & 1 deletion steem/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def getAccount(self, pub):
return {"name": None, "type": None, "pubkey": pub}
else:
try:
account = Account(name)
account = Account(name, steemd_instance=self.steemd)
except: # noqa FIXME(sneak)
return
keyType = self.getKeyType(account, pub)
Expand Down