mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
Update CLI for genesis Fix import paths from ethereum/go-ethereum to luxfi/geth - Replace all ethereum/go-ethereum imports with luxfi/geth - Add local rawdb package for unexported constants - Fix build errors in genesis tools - Add comprehensive migration documentation - Create build-all.sh script for building all tools - Clean up duplicate functions and unused imports Fix remaining imports Update CLI Remove symlink Remove local replace directives Update Update old templates
95 lines
1.9 KiB
Go
95 lines
1.9 KiB
Go
// Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
package models
|
|
|
|
import "sync"
|
|
|
|
type NodeResult struct {
|
|
NodeID string
|
|
Value interface{}
|
|
Err error
|
|
}
|
|
type NodeResults struct {
|
|
Results []NodeResult
|
|
Lock sync.Mutex
|
|
}
|
|
|
|
func (nr *NodeResults) AddResult(nodeID string, value interface{}, err error) {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
nr.Results = append(nr.Results, NodeResult{
|
|
NodeID: nodeID,
|
|
Value: value,
|
|
Err: err,
|
|
})
|
|
}
|
|
|
|
func (nr *NodeResults) GetResults() []NodeResult {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
return nr.Results
|
|
}
|
|
|
|
func (nr *NodeResults) GetResultMap() map[string]interface{} {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
result := map[string]interface{}{}
|
|
for _, node := range nr.Results {
|
|
result[node.NodeID] = node.Value
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (nr *NodeResults) Len() int {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
return len(nr.Results)
|
|
}
|
|
|
|
func (nr *NodeResults) GetNodeList() []string {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
nodes := []string{}
|
|
for _, node := range nr.Results {
|
|
nodes = append(nodes, node.NodeID)
|
|
}
|
|
return nodes
|
|
}
|
|
|
|
func (nr *NodeResults) GetErrorHostMap() map[string]error {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
hostErrors := make(map[string]error)
|
|
for _, node := range nr.Results {
|
|
if node.Err != nil {
|
|
hostErrors[node.NodeID] = node.Err
|
|
}
|
|
}
|
|
return hostErrors
|
|
}
|
|
|
|
func (nr *NodeResults) HasIDWithError(id string) bool {
|
|
nr.Lock.Lock()
|
|
defer nr.Lock.Unlock()
|
|
for _, node := range nr.Results {
|
|
if node.NodeID == id && node.Err != nil {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (nr *NodeResults) HasErrors() bool {
|
|
return len(nr.GetErrorHostMap()) > 0
|
|
}
|
|
|
|
func (nr *NodeResults) GetErrorHosts() []string {
|
|
var nodes []string
|
|
for _, node := range nr.Results {
|
|
if node.Err != nil {
|
|
nodes = append(nodes, node.NodeID)
|
|
}
|
|
}
|
|
return nodes
|
|
}
|