You are viewing a single comment's thread from:

RE: Steem-lib, Intro.

in #steem-lib8 years ago

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)
})