Beispiel #1
0
    def custom_json_dict(self, custom_json_dict):
        """Calc RC costs for a custom_json

        Example for calculating RC costs

        .. code-block:: python

            from beem.rc import RC
            from collections import OrderedDict
            custom_json_dict = {
                                 "json": [
                                          "reblog", OrderedDict([("account", "xeroc"), ("author", "chainsquad"),
                                                                 ("permlink", "streemian-com-to-open-its-doors-and-offer-a-20-discount")
                                                                ])
                                         ],
                                 "required_auths": [],
                                 "required_posting_auths": ["xeroc"],
                                 "id": "follow"
                                }

            rc = RC()
            print(rc.comment(custom_json_dict))

        """
        op = operations.Custom_json(**custom_json_dict)
        tx_size = self.get_tx_size(op)
        follow_id = custom_json_dict["id"] == "follow"
        return self.custom_json(tx_size=tx_size, follow_id=follow_id)
    def time_custom_json(self):
        self.op = operations.Custom_json(
            **{
                "json": [
                    "reblog",
                    OrderedDict(
                        [  # need an ordered dict to keep order for the test
                            ("account", "xeroc"), ("author", "chainsquad"),
                            ("permlink", "streemian-com-to-open-its-doors-"
                             "and-offer-a-20-discount")
                        ])
                ],
                "required_auths": [],
                "required_posting_auths": ["xeroc"],
                "id":
                "follow",
                "prefix":
                self.default_prefix
            })

        self.doit()
# print(rc.comment()) #(self, tx_size=1000, permlink_length=10, parent_permlink_length=10)
# print(rc.vote()) #(self, tx_size=210)
# print(rc.transfer()) #(self, tx_size=290, market_op_count=1)
# print(rc.custom_json())

account = "hrm-user"

json = {'command': 'create'}
# json = {
#     'command': 'confirmation',
#     'transaction': '33715240:24',
#     'status': 'OK'
#     }

id = "institutionList"

op = operations.Custom_json(
    **{
        "json": json,
        "required_auths": [],
        "required_posting_auths": [account],
        "id": id
    })

custom_tx = rc.get_tx_size(op)

custom_json_RC_costs = rc.custom_json(custom_tx)

print(custom_json_RC_costs)