SteemWhistle: A .NET library that exposes the Steem blockchain as Reactive Extensions Observables

in steem •  9 years ago 

Announcing SteemWhistle: A library that lets you stream and query the Steem blockchain using LINQ and Rx.

I've just checked in the really early bits for SteemWhistle, which includes a rudimentary vote bot as a sample.
All you need is to clone https://github.com/Auxon/SteemWhistle to get started.

The SteemVoteBot is a simple bot that demonstrates the use of the library, so take a look at it and let me know what you think!

Here's a sample of the code you can write:

        var globalPropertiesObservable = GlobalPropertiesObservable.Create("ws://localhost:8090").Publish();
        var blockObservable = BlockObservable.Create("ws://localhost:8090", globalPropertiesObservable).Publish();
        var transactionsObservable = TransactionsObservable.Create(blockObservable).Publish();
        var postsAndCommentsObservable = PostsAndCommentsObservable.Create(transactionsObservable).Publish();
        var commentsObservable = CommentsObservable.Create(postsAndCommentsObservable).Publish();
        var postsObservable = PostsObservable.Create(postsAndCommentsObservable).Publish();
        var votesObservable = VotesObservable.Create(transactionsObservable).Publish();

        globalPropertiesObservable.Connect();
        blockObservable.Connect();
        transactionsObservable.Connect();
        postsAndCommentsObservable.Connect();
        commentsObservable.Connect();
        postsObservable.Connect();
        votesObservable.Connect();

        globalPropertiesObservable.Subscribe((globalProperties) =>
        {
            Console.WriteLine("head_block_number = " + globalProperties.head_block_number);
        }, (ex) => Console.WriteLine(ex.Message));

        blockObservable.Subscribe(block =>
        {
            Console.WriteLine("Block arrived.  # of transactions = " + block.transactions?.Count());
        }, (ex) => Console.WriteLine(ex.Message));

        var q = from block in blockObservable
                from transaction in block.transactions
                select transaction.signatures;

Many thanks to @xeroc, @theoretical, and others for posting their code that helped me figure out what to do.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!