MCPcopy Create free account
hub / github.com/ethstorage/es-node / UploadNodeState

Method UploadNodeState

ethstorage/node/node.go:377–464  ·  view source on GitHub ↗
(url string)

Source from the content-addressed store, hash-verified

375}
376
377func (n *EsNode) UploadNodeState(url string) {
378 <-time.After(2 * time.Minute)
379 localNode := n.p2pNode.Dv5Local().Node()
380 id := localNode.ID().String()
381 helloUrl := fmt.Sprintf("%s/hello", url)
382 stateUrl := fmt.Sprintf("%s/reportstate", url)
383 _, err := sendMessage(helloUrl, id)
384 if err != nil {
385 n.lg.Warn("Send message to resp", "err", err.Error())
386 return
387 }
388 ticker := time.NewTicker(5 * time.Minute)
389 defer ticker.Stop()
390 for {
391 select {
392 case <-ticker.C:
393 state := NodeState{
394 Id: id,
395 Contract: n.storageManager.ContractAddress().Hex(),
396 Version: n.appVersion,
397 Address: fmt.Sprintf("%s:%d", localNode.IP().String(), localNode.TCP()),
398 SavedBlobs: n.storageManager.KvEntryCount(),
399 DownloadedBlobs: n.downloader.GetState(),
400 ScanStats: n.scanner.GetScanState(),
401 }
402
403 var submissionStates map[uint64]*miner.SubmissionState
404 if status, _ := n.db.Get(miner.SubmissionStatusKey); status != nil {
405 if err := json.Unmarshal(status, &submissionStates); err != nil {
406 n.lg.Error("Failed to decode submission states", "err", err)
407 continue
408 }
409 }
410 var miningStates map[uint64]*miner.MiningState
411 if status, _ := n.db.Get(miner.MiningStatusKey); status != nil {
412 if err := json.Unmarshal(status, &miningStates); err != nil {
413 n.lg.Error("Failed to decode submission states", "err", err)
414 continue
415 }
416 }
417 var providedBlobs map[uint64]uint64
418 if status, _ := n.db.Get(protocol.ProvidedBlobsKey); status != nil {
419 if err := json.Unmarshal(status, &providedBlobs); err != nil {
420 n.lg.Error("Failed to decode provided Blobs count", "err", err)
421 continue
422 }
423 }
424 var syncStates map[uint64]*protocol.SyncState
425 if status, _ := n.db.Get(protocol.SyncStatusKey); status != nil {
426 if err := json.Unmarshal(status, &syncStates); err != nil {
427 n.lg.Error("Failed to decode sync states", "err", err)
428 continue
429 }
430 }
431
432 shards := make([]*ShardState, 0)
433 for _, shardId := range n.storageManager.Shards() {
434 miner, _ := n.storageManager.GetShardMiner(shardId)

Callers 1

StartMethod · 0.95

Calls 13

Dv5LocalMethod · 0.80
GetStateMethod · 0.80
GetScanStateMethod · 0.80
GetMethod · 0.80
sendMessageFunction · 0.70
IDMethod · 0.65
ContractAddressMethod · 0.65
KvEntryCountMethod · 0.65
ShardsMethod · 0.65
GetShardMinerMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected