Steem-lib, Intro.

in #steem-lib7 years ago (edited)

A javascript library that's I had been working on during past few months.

This post is just a quick walk-through about its overall structure.

Usage

  • a Steem client that could be configured to stay connected with multi-servers.
  • to make Steem API calls, to construct transactions, signing & broadcast.
  • listening to blocks, and transactions.

Codes Structure

The overall structure is basically an imitation of ripplelib that I had been using. The main components are some nodejs EventListeners object: Remote, Server, Request, Transaction, TransactionManager.

Most other underlying codes are directly copied and modified from steemjs-lib and official steem-js repositories.

There's no ES6 syntax in these codes, nor any use of promises. And I'm preferring flat structure, so every source-files just goes into one single folder.

included in the /build folder are the pre-build js and min.js that's ready for browser use.

Release:

https://github.com/ripplerm/steem-lib
https://www.npmjs.com/package/steem-lib

More details in my next posts...

Sort:  

how those settings with multiple servers works? Can I set up a threshold after which request will be made to next server as fallback?

PS. Upvoted, Resteemed on Steemit and Stared on Github :)

PS.2. I've just noticed, that you also published guide to this library - to not miss next ones, I also following you now :)

by default, the client will only sent the API calls to one of the connected servers, and it won't fallback to next servers should any error occur.

However, there's a workaround to force an API request to be submitted to all servers.

To use this, you have to call the method in the form of taking arguments as an options-object (as explained in the Guide), and pass in a validating function as 'broadcast' property. The client will sent the APi calls to all servers simultaneously, and callback as soon as it saw a response that pass the validating function... if all failed then the callback will be called with last-received-result.

Example:

var validator =  function (res) {
    // check if it's a valid block
    if (res && res.previous) return true;
    return false;
}

remote.get_block_with({
    blockNum: 960123,
    broadcast: validator,
}, function(err, res) {
    console.log(err, res)
})

thank you for advertising this post @noisy - be happy to upvote @ripplerm over these libraries.
Let me introduce you to http://steemspeak.com where information travels faster, @ripplerm. :)

Solid logistical job on there, thanks for sharing the with us all. Namaste :)

Cool! 😎 I'll give it a look 👍

大神,请收下我的膝盖

Downvoted because of high rewards, What about new users coming to steemit reading such complicated stuff.

I can't show this to any of my friends or family, for example. I don't know a single person outside of Steemit who has any interest in something like this. If any case can be made for content driving growth (and I'm very skeptical), it is going to have to have some kind of broad appeal. Or at the very least, appeal to some segment of the outside world. (edit; borrowed this last paragraph from bachist, I don't need to invent the wheel all over, do I?)

Steemit/steem is still in the construction phase. Would you invite your friends/family to a housewarming party if there was no roof in your new home?

I actually didn't down vote.
I was testing how such irrational arguments would work under other post.

But I'm a little surprised about your reply. And I have to ask you two question to get things clear.
Are you suggesting I'll wait with introducing friends and family to this platform until it's finished? (or how do you say it, in full operation/)
When the finished version is presented do you think the technical nerd stuff will stop? Not to offend anyone;) I have high respect for so called "nerds"
edited; language mistakes

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.032
BTC 69516.92
ETH 3835.82
USDT 1.00
SBD 3.72