Skip to content

Commit

Permalink
Update v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
george012 committed Apr 30, 2024
1 parent 1f54080 commit 86d658e
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 19 deletions.
94 changes: 94 additions & 0 deletions blockchain_node_flag/blockchain_node_flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Package blockchain_node_flag blockchain node flags(zh-cn:区块链节点标识)
*/
package blockchain_node_flag

var (
SupportedBlockChainNodes = map[string]BlockChainNodeFlag{
BlockChainNodeFlagBitCoin.NodeServiceName(): BlockChainNodeFlagBitCoin,
BlockChainNodeFlagLiteCoin.NodeServiceName(): BlockChainNodeFlagLiteCoin,
BlockChainNodeFlagDogeCoin.NodeServiceName(): BlockChainNodeFlagDogeCoin,
BlockChainNodeFlagETC.NodeServiceName(): BlockChainNodeFlagETC,
BlockChainNodeFlagETHW.NodeServiceName(): BlockChainNodeFlagETHW,
BlockChainNodeFlagZIL.NodeServiceName(): BlockChainNodeFlagZIL,
BlockChainNodeFlagOCTA.NodeServiceName(): BlockChainNodeFlagOCTA,
BlockChainNodeFlagMETA.NodeServiceName(): BlockChainNodeFlagMETA,
BlockChainNodeFlagCAU.NodeServiceName(): BlockChainNodeFlagCAU,
}
)

type BlockChainNodeFlag int

// server常量
const (
BlockChainNodeFlagNone BlockChainNodeFlag = iota
BlockChainNodeFlagBitCoin
BlockChainNodeFlagLiteCoin
BlockChainNodeFlagDogeCoin
BlockChainNodeFlagETC
BlockChainNodeFlagETHW
BlockChainNodeFlagZIL
BlockChainNodeFlagOCTA
BlockChainNodeFlagMETA
BlockChainNodeFlagCAU
)

// GetBlockChainNodeFlagFromCoinName 根据coinName 获取节点标识
func GetBlockChainNodeFlagFromCoinName(coinName string) BlockChainNodeFlag {
switch coinName {
case "BTC", "BitCoin":
return BlockChainNodeFlagBitCoin
case "LTC", "LiteCoin":
return BlockChainNodeFlagLiteCoin
case "DOGE", "Doge coin", "Dogecoin":
return BlockChainNodeFlagDogeCoin
case "ETC", "Ethereum Classic", "EthereumClassic":
return BlockChainNodeFlagETC
case "ETHW", "Ethereum PoW", "EthereumPoW":
return BlockChainNodeFlagETHW
case "ZIL", "Zilliqa":
return BlockChainNodeFlagZIL
case "OCTA", "OctaSpace":
return BlockChainNodeFlagOCTA
case "META", "MetaChain":
return BlockChainNodeFlagMETA
case "CAU", "Canxium":
return BlockChainNodeFlagCAU
default:
return BlockChainNodeFlagNone
}
}

// TODO 未定稿
// NodeServiceName 节点服务名称
func (bcnf BlockChainNodeFlag) NodeServiceName() string {
switch bcnf {
case BlockChainNodeFlagBitCoin:
return "btcd"
case BlockChainNodeFlagLiteCoin:
return "litecoind"
case BlockChainNodeFlagDogeCoin:
return "dogecoind"
case BlockChainNodeFlagETC:
return "core_geth"
case BlockChainNodeFlagETHW:
return "ethw_geth"
case BlockChainNodeFlagZIL:
return "zilliqa"
case BlockChainNodeFlagOCTA:
return "octa_geth"
case BlockChainNodeFlagMETA:
return "meta_geth"
case BlockChainNodeFlagCAU:
return "cau_geth"
default:
return "none"
}
}

// TODO END 未定稿

func IsCustomService(serviceName string) bool {
_, exists := SupportedBlockChainNodes[serviceName]
return exists
}
35 changes: 19 additions & 16 deletions coin_flags/coin_flags.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
Package coin_flags coin flags(zh-cn:币种标识)
*/
package coin_flags

var (
Expand All @@ -19,12 +22,12 @@ type CoinFlag int
const (
CoinFlagNone CoinFlag = iota
CoinFlagBTC
CoinFlagLTC
CoinFlagDOGE
CoinFlagETC
CoinFlagETHW
CoinFlagZIL
CoinFlagOCTA
CoinFlagLTC
CoinFlagDOGE
CoinFlagMETA
CoinFlagCAU
)
Expand All @@ -33,6 +36,10 @@ func GetCoinFlagByCoinName(name string) CoinFlag {
switch name {
case "BTC", "BitCoin", "Bitcoin":
return CoinFlagBTC
case "LTC", "LiteCoin", "Litecoin":
return CoinFlagLTC
case "DOGE", "DogeCoin", "Dogecoin":
return CoinFlagDOGE
case "ETC", "Ethereum Classic", "EthereumClassic":
return CoinFlagETC
case "ETHW", "EthereumPoW":
Expand All @@ -41,10 +48,6 @@ func GetCoinFlagByCoinName(name string) CoinFlag {
return CoinFlagZIL
case "OCTA", "OctaSpace":
return CoinFlagOCTA
case "LTC", "LiteCoin", "Litecoin":
return CoinFlagLTC
case "DOGE", "DogeCoin", "Dogecoin":
return CoinFlagDOGE
case "META", "MetaChain":
return CoinFlagMETA
case "CAU", "Canxium":
Expand All @@ -58,6 +61,10 @@ func (cf CoinFlag) CoinName() string {
switch cf {
case CoinFlagBTC:
return "BTC"
case CoinFlagLTC:
return "LTC"
case CoinFlagDOGE:
return "DOGE"
case CoinFlagETC:
return "ETC"
case CoinFlagETHW:
Expand All @@ -66,23 +73,23 @@ func (cf CoinFlag) CoinName() string {
return "ZIL"
case CoinFlagOCTA:
return "OCTA"
case CoinFlagLTC:
return "LTC"
case CoinFlagDOGE:
return "DOGE"
case CoinFlagMETA:
return "META"
case CoinFlagCAU:
return "CAU"
default:
return "None"
return "none"
}
}

func (cf CoinFlag) CoinFullName() string {
switch cf {
case CoinFlagBTC:
return "Bitcoin"
case CoinFlagLTC:
return "Litecoin"
case CoinFlagDOGE:
return "Dogecoin"
case CoinFlagETC:
return "EthereumClassic"
case CoinFlagETHW:
Expand All @@ -91,16 +98,12 @@ func (cf CoinFlag) CoinFullName() string {
return "Zilliqa"
case CoinFlagOCTA:
return "OctaSpace"
case CoinFlagLTC:
return "Litecoin"
case CoinFlagDOGE:
return "Dogecoin"
case CoinFlagMETA:
return "MetaChain"
case CoinFlagCAU:
return "Canxium"
default:
return "None"
return "none"
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ package config

const (
ProjectName = "blockchain_box"
ProjectVersion = "v0.0.8"
ProjectVersion = "v0.0.9"
ProjectDescription = "[blockchain] box"
)
2 changes: 1 addition & 1 deletion service_info/service_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (rm ServiceFlag) String() string {
case ServiceFlagThirdParty:
return "third_party_service"
default:
return "None"
return "none"
}
}

Expand Down
11 changes: 10 additions & 1 deletion third_party_service/third_party_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Package third_party_service Third-party services(zh-cn:第三方服务)
*/
package third_party_service

import (
"github.com/george012/blockchain_box/service_info"
)

var (
// SupportedThirdPartyServices 已支持的第三方服务Map
SupportedThirdPartyServices = map[string]ThirdPartyServiceFlag{
Expand Down Expand Up @@ -48,7 +52,7 @@ func (tpsf ThirdPartyServiceFlag) ServiceName() string {
case ThirdPartyServiceFlagNginx:
return "nginx"
default:
return "None"
return "none"
}
}

Expand All @@ -58,3 +62,8 @@ func IsCSupported(serviceName string) bool {
_, exists := SupportedThirdPartyServices[serviceName]
return exists
}

type ServiceInfoThirdParty struct {
ServiceInfoBase service_info.ServiceInfoBase // 基础信息
ThirdPartyServiceFlag ThirdPartyServiceFlag // 第三方服务标识
}

0 comments on commit 86d658e

Please sign in to comment.