-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2577 from 0chain/users/sunilmhta/fix/2544/0chain/…
…usingmap
- Loading branch information
Showing
4 changed files
with
161 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package dto | ||
|
||
import ( | ||
"0chain.net/core/common" | ||
"0chain.net/smartcontract/provider" | ||
"github.com/0chain/common/core/currency" | ||
) | ||
|
||
// NodeType used in pools statistic. | ||
type NodeType int | ||
|
||
// MinerDtoNode struct that holds information about the registering miner. | ||
// swagger:model MinerDtoNode | ||
type MinerDtoNode struct { | ||
*SimpleDtoNode `json:"simple_miner,omitempty"` | ||
*StakePool `json:"stake_pool,omitempty"` | ||
} | ||
|
||
// swagger:model SimpleDtoNode | ||
type SimpleDtoNode struct { | ||
provider.Provider | ||
N2NHost string `json:"n2n_host"` | ||
Host string `json:"host"` | ||
Port int `json:"port"` | ||
Geolocation SimpleNodeGeolocation `json:"geolocation"` | ||
Path string `json:"path"` | ||
PublicKey string `json:"public_key"` | ||
ShortName string `json:"short_name"` | ||
BuildTag string `json:"build_tag"` | ||
TotalStaked currency.Coin `json:"total_stake"` | ||
Delete bool `json:"delete"` | ||
|
||
// settings and statistic | ||
|
||
// NodeType used for delegate pools statistic. | ||
NodeType NodeType `json:"node_type,omitempty"` | ||
|
||
// LastHealthCheck used to check for active node | ||
LastHealthCheck common.Timestamp `json:"last_health_check"` | ||
|
||
// Status will be set either node.NodeStatusActive or node.NodeStatusInactive | ||
Status int `json:"-" msg:"-"` | ||
|
||
//LastSettingUpdateRound will be set to round number when settings were updated | ||
LastSettingUpdateRound int64 `json:"last_setting_update_round"` | ||
} | ||
|
||
// swagger:model SimpleNodeGeolocation | ||
type SimpleNodeGeolocation struct { | ||
Latitude *float64 `json:"latitude,omitempty"` | ||
Longitude *float64 `json:"longitude,omitempty"` | ||
} | ||
|
||
func NewMinerDtoNode() *MinerDtoNode { | ||
return &MinerDtoNode{ | ||
SimpleDtoNode: &SimpleDtoNode{ | ||
Provider: provider.Provider{}, | ||
}, | ||
StakePool: NewStakePool(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dto | ||
|
||
import ( | ||
cstate "0chain.net/chaincore/chain/state" | ||
"0chain.net/core/common" | ||
"github.com/0chain/common/core/currency" | ||
) | ||
|
||
type PoolStatus int | ||
|
||
// StakePool holds delegate information for an 0chain providers | ||
type StakePool struct { | ||
Pools map[string]*DelegatePool `json:"pools"` | ||
Reward currency.Coin `json:"rewards"` | ||
StakePoolSettings Settings `json:"settings"` | ||
Minter cstate.ApprovedMinter `json:"minter"` | ||
HasBeenKilled bool `json:"is_dead"` | ||
} | ||
|
||
type DelegatePool struct { | ||
Balance currency.Coin `json:"balance"` | ||
Reward currency.Coin `json:"reward"` | ||
Status *PoolStatus `json:"status"` | ||
RoundCreated *int64 `json:"round_created"` // used for cool down | ||
DelegateID *string `json:"delegate_id"` | ||
StakedAt common.Timestamp `json:"staked_at"` | ||
} | ||
|
||
type Settings struct { | ||
DelegateWallet *string `json:"delegate_wallet,omitempty"` | ||
MaxNumDelegates *int `json:"num_delegates,omitempty"` | ||
ServiceChargeRatio *float64 `json:"service_charge,omitempty"` | ||
} | ||
|
||
func NewStakePool() *StakePool { | ||
return &StakePool{ | ||
Pools: make(map[string]*DelegatePool), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters