Beispiel #1
0
    def comment_dict(self, comment_dict):
        """Calc RC costs for a comment dict object

        Example for calculating RC costs

        .. code-block:: python

            from beem.rc import RC
            comment_dict = {
                            "permlink": "test", "author": "holger80",
                            "body": "test", "parent_permlink": "",
                            "parent_author": "", "title": "test",
                            "json_metadata": {"foo": "bar"}
                           }

            rc = RC()
            print(rc.comment_from_dict(comment_dict))

        """
        op = operations.Comment(**comment_dict)
        tx_size = self.get_tx_size(op)
        permlink_length = len(comment_dict["permlink"])
        parent_permlink_length = len(comment_dict["parent_permlink"])
        return self.comment(tx_size=tx_size,
                            permlink_length=permlink_length,
                            parent_permlink_length=parent_permlink_length)
    def time_utf8tests(self):
        self.op = operations.Comment(
            **{
                "parent_author": "",
                "parent_permlink": "",
                "author": "a",
                "permlink": "a",
                "title": "-",
                "body": "".join([chr(i) for i in range(0, 2048)]),
                "json_metadata": {},
                "prefix": self.default_prefix
            })

        self.doit()
    def time_Comment(self):
        self.op = operations.Comment(
            **{
                "parent_author": "foobara",
                "parent_permlink": "foobarb",
                "author": "foobarc",
                "permlink": "foobard",
                "title": "foobare",
                "body": "foobarf",
                "json_metadata": {
                    "foo": "bar"
                },
                "prefix": self.default_prefix
            })

        self.doit()