Technical Updates

in #spk2 years ago (edited)

Making Some Buttons Work

Behind the Button

Coming from an electrical engineering background a button just couldn't be easier... a momentary contact of two electrical conductors. But building decentralized systems can really complicate things.

Part of the SPK Network is incentivizing people at large to store files. So naturally one of the things a person needs to be able to do is store a file. Alternatively, imagine you write a script to find files to store... and you stumble upon a video on Hive that you would rather not be associated with. How to you easily remove this from your storage?

Well the ethos I have in mind is that the network should be modular enough that you only have to run the pieces that make sense to run. If every person is running a block processor then the Hive API nodes have to be that much beefier and well, there isn't a need for it. We strive for meaningful decentralization, not total decentralization. Running a storage node should mean you put most of your disk space toward storage, and as little as necessary for managing that storage.

SPK Network

Above you can see the simplest diagram showing the flow of information. Hive only takes signed transactions as inputs. SPK Network Node only takes Hive Blocks as inputs. Trole coordinates user uploads via SPK Network. Anybody can run an IPFS node, a SPK Network node, or a Hive node; Trole manages files on IPFS, and Proof of Access... well... proves access to files on IPFS. You can run several combinations of this suite:

TypeSPK NodeTrolePoAIPFSHive
FullXXXXX
ValidatorXXXX
Validator MinXXX
SPK NodeX
Storage UploadXXX
Desktop App~XX
Manual MinimumXX

We are hoping to provide incentives to the average desktop user, the desktop app should manage your IPFS system and will include PoA. The manual minimum would require you to manually add files to IPFS and run the PoA system (you are more than welcome to write management software to your needs).

We are expecting Storage/Upload and Desktop Apps to be the most utilized set up. There is a need for 20 Validators and of course anybody who wants to run a validator enabled node will enjoy incentives aligned with the votes they've received in the system. Running your own Hive node just isn't needed at nearly any level, but is included for the sake of understanding it is an intrinsic part of the ecosystem.

Onward to the Buttons

Well, the desktop app will have some very easy to use buttons, after all there is no need to communicate your needs over the network... but you will still have to announce you are storing certain files. However, when you're running an upload node it likely isn't on your computer and is in the cloud somewhere.

Trole has some lifecycle checks, it polls some data from speak network and (currently) checks it's total inventory rotating thru 100 minutes.

Live Stats

This checks to see if it's contracts are still active, cleans any paused or failed uploads out of its temp directory after 24 hours. and most importantly polls the spk api feed for new additions.

24 hour Feed

As the network grows this feed check could get a little out of hand. So I wrote a new DB handler to ease the load on both the SPK node as well as on Trole.

Feed Since

This new call means you only will need to process the last 10 minutes of feed and won't have to recheck anything but the last block(which is included in case you queried the feed mid block and missed something).

Interesting Bits

The highlighted section here are made from a user signing a transaction after hitting the button we talked about.

fetch(`${config.SPK_API}/feed${live_stats.feed ? '/' + live_stats.feed : ''}`).then(rz => rz.json()).then(json => {
    const feed = json.feed
    const keys = Object.keys(json.feed)
    const stored = `@${config.account} Stored`
    const deleted = `@${config.account} Removed`
    for (var i = 0; i < keys.length; i++) {
      if(parseInt(keys[i].split(':')[0]) > live_stats.feed) live_stats.feed = parseInt(keys[i].split(':')[0])
      if (feed[keys[i]].search(stored) > -1) {
        storeByContract(feed[keys[i]].split('|')[1])
      } else if (feed[keys[i]].search(deleted) > -1){
        deleteByContract(feed[keys[i]].split('|')[1])
      }
    }
  })

Which is read and acted upon by the polling routine here. And yes, it works on a list of contracts as well if you make a hive transaction that includes storing or deleting several contracts.

Contract in Array

Github

Trole itself should be feature complete for this release but will include some more updates on the install scripts and documentation. Feel free to peruse the repo and ... the install script should work as a non-root user on an ubuntu system. But i encourage you to read the install script. Any pull requests will be considered and most likely handsomely rewarded via upvotes and bug bounties. This is still early alpha software but getting some people to understand what's going on here can't begin soon enough. We need feedback if there is a feature that we missed that is useful enough to include.

Next Steps

Trelo

This is what's currently on my plate. SPK-JS needs to be able to cordinate contracts, prepare and upload files, and get information from the network to manage contracts.

PoA needs to be integrated with the token distribution mechanism talked about in the meeting 2 weeks ago.

You Can...

Tune in to our next public meeting every Thursday at noon California time.
Provide feedback and ask question here or on any of my blogs, or find me on discord
Vote for my Witness

Sort:  

holy work, i am not in that level yet but looks like very difficult

It's all just legos. Same 8 pieces... but arranged in ever more complicated ways.

Imagine having to develop all of that! God, geez that would be stressful.

untitled.gif