(url string)
| 375 | } |
| 376 | |
| 377 | func (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) |
no test coverage detected