How to use the bytebuffer.Long.ZERO function in bytebuffer

To help you get started, we’ve selected a few bytebuffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freedomexio / rocketx-condenser / src / app / utils / StateFunctions.js View on Github external
export function contentStats(content, precision) {
    if (!content) return {};
    if (!(content instanceof Map)) content = fromJS(content);

    let net_rshares_adj = Long.ZERO;
    let neg_rshares = Long.ZERO;
    let total_votes = 0;
    let up_votes = 0;

    const minDigits = precision
        ? Math.max(0, precision - 2)
        : Math.log10(SCOT_DENOM) - 2;

    // TODO: breaks if content has no active_votes attribute.

    content.get('active_votes').forEach(v => {
        const sign = Math.sign(v.get('percent'));
        if (sign === 0) return;
        total_votes += 1;
        if (sign > 0) up_votes += 1;
github freedomexio / rocketx-condenser / app / utils / StateFunctions.js View on Github external
export function contentStats(content) {
    if(!content) return {}
    if(!(content instanceof Map)) content = fromJS(content);

    let net_rshares_adj = Long.ZERO
    let neg_rshares = Long.ZERO
    let total_votes = 0;
    let up_votes = 0;

    content.get('active_votes').forEach((v) => {
        const sign = Math.sign(v.get('percent'))
        if(sign === 0) return;
        total_votes += 1
        if(sign > 0) up_votes += 1

        const rshares = String(v.get('rshares'))

        // For flag weight: count total neg rshares
        if(sign < 0) {
            neg_rshares = neg_rshares.add(rshares)
        }
github freedomexio / rocketx-condenser / src / app / utils / StateFunctions.js View on Github external
export function contentStats(content, precision) {
    if (!content) return {};
    if (!(content instanceof Map)) content = fromJS(content);

    let net_rshares_adj = Long.ZERO;
    let neg_rshares = Long.ZERO;
    let total_votes = 0;
    let up_votes = 0;

    const minDigits = precision
        ? Math.max(0, precision - 2)
        : Math.log10(SCOT_DENOM) - 2;

    // TODO: breaks if content has no active_votes attribute.

    content.get('active_votes').forEach(v => {
        const sign = Math.sign(v.get('percent'));
        if (sign === 0) return;
        total_votes += 1;
        if (sign > 0) up_votes += 1;

        const rshares = String(v.get('rshares'));
github freedomexio / rocketx-condenser / app / utils / StateFunctions.js View on Github external
export function contentStats(content) {
    if(!content) return {}
    if(!(content instanceof Map)) content = fromJS(content);

    let net_rshares_adj = Long.ZERO
    let neg_rshares = Long.ZERO
    let total_votes = 0;
    let up_votes = 0;

    content.get('active_votes').forEach((v) => {
        const sign = Math.sign(v.get('percent'))
        if(sign === 0) return;
        total_votes += 1
        if(sign > 0) up_votes += 1

        const rshares = String(v.get('rshares'))

        // For flag weight: count total neg rshares
        if(sign < 0) {
            neg_rshares = neg_rshares.add(rshares)
        }
github Someguy123 / understeem / app / components / cards / PostFull.jsx View on Github external
const content_body = content.body;
        const {category, title, body} = content;
        if (process.env.BROWSER && title) document.title = title + ' — Steemit';

        const replyParams = {author, permlink, parent_author, parent_permlink, category, title, body}

        let net_rshares = Long.ZERO
        post_content.get('active_votes', List()).forEach(v => {
            // ? Remove negative votes unless full power -1000 (we had downvoting spam)
            const percent = v.get('percent')
            if(percent < 0 /*&& percent !== -1000*/) return
            net_rshares = net_rshares.add(Long.fromString(String(v.get('rshares'))))
        })
        const showDeleteOption = username === author &&
            post_content.get('replies', List()).size === 0 &&
            net_rshares.compare(Long.ZERO) <= 0

        this.share_params = {
            url: 'https://steemit.com' + link,
            title: title + ' — Steemit',
            desc: p.desc
        };

        const share_menu = [
            {link: '#', onClick: this.fbShare, value: 'Facebook', icon: 'facebook'},
            {link: '#', onClick: this.twitterShare, value: 'Twitter', icon: 'twitter'},
            {link: '#', onClick: this.linkedInShare, value: 'LinkedIn', icon: 'linkedin'},
        ];
        const Editor = this.state.showReply ? PostFullReplyEditor : PostFullEditEditor
        let renderedEditor = null;
        if (showReply || showEdit) {
            renderedEditor = <div></div>
github freedomexio / rocketx-condenser / src / app / utils / StateFunctions.js View on Github external
// take negative rshares, divide by 2, truncate 10 digits (plus neg sign), count digits.
    // creates a cheap log10, stake-based flag weight. 1 = approx $400 of downvoting stake; 2 = $4,000; etc
    const flagWeight = Math.max(
        String(neg_rshares.div(2)).length - minDigits - 1,
        0
    );

    // post must have non-trivial negative rshares to be grayed out. (more than 10 digits)
    const grayThreshold = -(Math.pow(10, minDigits) - 1);
    const meetsGrayThreshold = net_rshares_adj.compare(grayThreshold) &lt; 0;

    // to be eligible for deletion, a comment must have non-positive rshares and no replies
    const hasPositiveRshares = Long.fromString(
        String(content.get('net_rshares'))
    ).gt(Long.ZERO);
    const allowDelete = !hasPositiveRshares &amp;&amp; content.get('children') === 0;
    // Expecting this to come from SCOT data.
    const hasPendingPayout =
        (content.has('vote_rshares') &amp;&amp;
            parsePayoutAmount(content.get('vote_rshares')) &gt; 0) ||
        parsePayoutAmount(content.get('pending_payout_value')) &gt;= 0.02;
    const authorRepLog10 = repLog10(content.get('author_reputation'));

    const gray =
        !hasPendingPayout &amp;&amp; (authorRepLog10 &lt; 1 || meetsGrayThreshold);
    const hide = !hasPendingPayout &amp;&amp; authorRepLog10 &lt; 0; // rephide

    // Combine tags+category to check nsfw status
    const json = content.get('json_metadata');
    let tags = [];
    try {
github Someguy123 / understeem / app / components / cards / PostFull.jsx View on Github external
if (!post_content) return null;
        const p = extractContent(immutableAccessor, post_content);
        const content = post_content.toJS();
        const {author, permlink, parent_author, parent_permlink} = content
        const jsonMetadata = this.state.showReply ? null : p.json_metadata
        // let author_link = '/@' + content.author;
        let link = `/@${content.author}/${content.permlink}`;
        if (content.category) link = `/${content.category}${link}`;

        const content_body = content.body;
        const {category, title, body} = content;
        if (process.env.BROWSER &amp;&amp; title) document.title = title + ' — Steemit';

        const replyParams = {author, permlink, parent_author, parent_permlink, category, title, body}

        let net_rshares = Long.ZERO
        post_content.get('active_votes', List()).forEach(v =&gt; {
            // ? Remove negative votes unless full power -1000 (we had downvoting spam)
            const percent = v.get('percent')
            if(percent &lt; 0 /*&amp;&amp; percent !== -1000*/) return
            net_rshares = net_rshares.add(Long.fromString(String(v.get('rshares'))))
        })
        const showDeleteOption = username === author &amp;&amp;
            post_content.get('replies', List()).size === 0 &amp;&amp;
            net_rshares.compare(Long.ZERO) &lt;= 0

        this.share_params = {
            url: 'https://steemit.com' + link,
            title: title + ' — Steemit',
            desc: p.desc
        };
github freedomexio / rocketx-condenser / app / utils / StateFunctions.js View on Github external
if(!(rshares.substring(0, 1) === '-' &amp;&amp; rshares.length &lt; 11)) {
                net_rshares_adj = net_rshares_adj.add(rshares)
            }
        }
    });

    // take negative rshares, divide by 2, truncate 10 digits (plus neg sign), count digits.
    // creates a cheap log10, stake-based flag weight. 1 = approx $400 of downvoting stake; 2 = $4,000; etc
    const flagWeight = Math.max(String(neg_rshares.div(2)).length - 11, 0)

    // post must have non-trivial negative rshares to be grayed out. (more than 10 digits)
    const grayThreshold = -9999999999
    const meetsGrayThreshold = net_rshares_adj.compare(grayThreshold) &lt; 0

    // to be eligible for deletion, a comment must have non-positive rshares and no replies
    const hasPositiveRshares = Long.fromString(String(content.get('net_rshares'))).gt(Long.ZERO)
    const allowDelete = !hasPositiveRshares &amp;&amp; content.get('children') === 0
    const hasPendingPayout = parsePayoutAmount(content.get('pending_payout_value')) &gt;= 0.02
    const authorRepLog10 = repLog10(content.get('author_reputation'))

    const gray = !hasPendingPayout &amp;&amp; (authorRepLog10 &lt; 1 || (authorRepLog10 &lt; 65 &amp;&amp; meetsGrayThreshold))
    const hide = !hasPendingPayout &amp;&amp; (authorRepLog10 &lt; 0) // rephide

    // Combine tags+category to check nsfw status
    const json = content.get('json_metadata')
    let tags = []
    try {
        tags = (json &amp;&amp; JSON.parse(json).tags) || [];
        if(typeof tags == 'string') {
            tags = [tags];
        } if(!Array.isArray(tags)) {
            tags = [];