nl_tokens: Prepare json formatted status for each share
pl_tokens: function prepareJson ( shares ) { /*jshint maxcomplexity:11 */ /*jshint maxstatements:23 */ let json = [ ] ; for ( let i = 0 ; i < shares . length ; i ++ ) { let share = shares [ i ] ; json [ i ] = { } ; json [ i ] . id = share . id ; let status = '?' ; switch ( share . state ) { case 0 : status = 'stopped' ; break ; case 1 : status = 'running' ; break ; case 2 : status = 'errored' ; <mask> ; default : status = 'unknown' ; } json [ i ] . status = status ; json [ i ] . configPath = share . config . storagePath ; json [ i ] . uptime = prettyMs ( share . meta . uptimeMs ) ; json [ i ] . restarts = share . meta . numRestarts || 0 ; json [ i ] . peers = share . meta . farmerState . totalPeers || 0 ; json [ i ] . allocs = fixContractValue ( share . meta . farmerState . contractCount ) ; json [ i ] . dataReceivedCount = fixContractValue ( share . meta . farmerState . dataReceivedCount ) ; json [ i ] . delta = share . meta . farmerState . ntpStatus . delta ; json [ i ] . port = share . meta . farmerState . portStatus . listenPort ; json [ i ] . shared = share . meta . farmerState . spaceUsed ; json [ i ] . sharedPercent = share . meta . farmerState . percentUsed ; var bridgeCxStat = share . meta . farmerState . bridgesConnectionStatus ; switch ( bridgeCxStat ) { case 0 : json [ i ] . bridgeConnectionStatus = 'disconnected' ; break ; case 1 : json [ i ] . bridgeConnectionStatus = 'connecting' ; break ; case 2 : json [ i ] . bridgeConnectionStatus = 'confirming' ; break ; case 3 : json [ i ] . bridgeConnectionStatus = 'connected' ; break ; default : break ; } } return JSON . stringify ( json ) ; }