function stream() {
    // Setting the RPC node link based on the current index value
    steemStream.api.setOptions({ url: stream_nodes[0] });
    return new Promise((resolve, reject) => {
        console.log('Starting a new stream with ' + stream_nodes[0]);
        // Starting the steem operations stream
        steemStream.api.streamOperations((err, operation) => {
            // Errors are mostly caused by RPC nodes crashing
            if(err) return reject(err);
            // Resteems are inside custom_json operations
            if(settings.tweet_resteems && operation[0] === 'custom_json') {
                const op = JSON.parse(operation[1].json);
                // Checking if it's a resteem and if it's from one of the specified accounts
                if(op[0] === 'reblog' && steem_accounts.resteems.includes(op[1].account)) {
                    treatOperation(op[1].author, op[1].permlink, op[0]);
                }
            // Checking if it's a post (not a comment) made by one of the specified accounts
            } else if(settings.tweet_posts && operation[0] === 'comment' && steem_accounts.posts.includes(operation[1].author) && operation[1].parent_author === '') {
                treatOperation(operation[1].author, operation[1].permlink, operation[0]);
            }
        });
    // If an error occured, add 1 to the index and put it at 0 if it is out of bound
    // Then relaunch the stream since it crashed
    }).catch(err => {
        console.error('Stream error:', err.message, 'with', stream_nodes[0]);
        // Putting the node element at the end of the array
        stream_nodes.push(stream_nodes.shift());
        stream();
    });
}
// Streams steem operations, this function is recursive (it calls itself when the stream fails)
Streams steem operations, this function is recursive (it calls itself when the stream fails)
Streams steem operations this function is recursive ( it calls itself when the stream fails )
function stream() {
    steemStream.api.setOptions({ url: stream_nodes[0] });
    return new Promise((resolve, reject) => {
        console.log('Starting a new stream with ' + stream_nodes[0]);
        steemStream.api.streamOperations((err, operation) => {
            if(err) return reject(err);
            if(settings.tweet_resteems && operation[0] === 'custom_json') {
                const op = JSON.parse(operation[1].json);
                if(op[0] === 'reblog' && steem_accounts.resteems.includes(op[1].account)) {
                    treatOperation(op[1].author, op[1].permlink, op[0]);
                }
            } else if(settings.tweet_posts && operation[0] === 'comment' && steem_accounts.posts.includes(operation[1].author) && operation[1].parent_author === '') {
                treatOperation(operation[1].author, operation[1].permlink, operation[0]);
            }
        });
    }).catch(err => {
        console.error('Stream error:', err.message, 'with', stream_nodes[0]);
        stream_nodes.push(stream_nodes.shift());
        stream();
    });
}
function stream ( ) { steemStream . api . setOptions ( { url : stream_nodes [ 0 ] } ) ; return new Promise ( ( resolve , reject ) => { console . log ( 'Starting a new stream with ' + stream_nodes [ 0 ] ) ; steemStream . api . streamOperations ( ( err , operation ) => { if ( err ) return reject ( err ) ; if ( settings . tweet_resteems && operation [ 0 ] === 'custom_json' ) { const op = JSON . parse ( operation [ 1 ] . json ) ; if ( op [ 0 ] === 'reblog' && steem_accounts . resteems . includes ( op [ 1 ] . account ) ) { treatOperation ( op [ 1 ] . author , op [ 1 ] . permlink , op [ 0 ] ) ; } } else if ( settings . tweet_posts && operation [ 0 ] === 'comment' && steem_accounts . posts . includes ( operation [ 1 ] . author ) && operation [ 1 ] . parent_author === '' ) { treatOperation ( operation [ 1 ] . author , operation [ 1 ] . permlink , operation [ 0 ] ) ; } } ) ; } ) . catch ( err => { console . error ( 'Stream error:' , err . message , 'with' , stream_nodes [ 0 ] ) ; stream_nodes . push ( stream_nodes . shift ( ) ) ; stream ( ) ; } ) ; }
Streams steem operations, this function is recursive (it calls itself when the stream fails)
Streams steem operations this function is recursive ( it calls itself when the stream fails )
// Setting the RPC node link based on the current index value // Starting the steem operations stream // Errors are mostly caused by RPC nodes crashing // Resteems are inside custom_json operations // Checking if it's a resteem and if it's from one of the specified accounts // Checking if it's a post (not a comment) made by one of the specified accounts // If an error occured, add 1 to the index and put it at 0 if it is out of bound // Then relaunch the stream since it crashed // Putting the node element at the end of the array