-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
19 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,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 | ||
} |
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
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