This commit is contained in:
lzx
2025-10-27 16:27:33 +08:00
parent b7c84fd101
commit b1d3e07c36
14 changed files with 2982 additions and 948 deletions

View File

@@ -6,8 +6,8 @@ import (
)
type IChainServer interface {
AddAddress(address string, msg any)
RemoveAddress(address string)
AddAddress(address string, msg any) error
RemoveAddress(address string) error
Listen(symbol string, ch chan any)
Transfer(symbol string, msg any) error
Stop()
@@ -30,21 +30,23 @@ func (b *BlockChainServer) RegisterChain(name string, chain IChainServer) {
b.chains[name] = chain
}
func (b *BlockChainServer) AddAddress(chain, address string, msg any) {
func (b *BlockChainServer) AddAddress(chain, address string, msg any) error {
if srv, ok := b.chains[chain]; ok {
srv.AddAddress(address, msg)
fmt.Printf("✅ 添加监听地址: chain=%s, address=%s\n", chain, address)
return nil
} else {
fmt.Printf("⚠️ 链未注册: %s\n", chain)
return fmt.Errorf("⚠️ 链未注册: %s\n", chain)
}
}
func (b *BlockChainServer) RemoveAddress(chain, address string) {
func (b *BlockChainServer) RemoveAddress(chain, address string) error {
if srv, ok := b.chains[chain]; ok {
srv.RemoveAddress(address)
fmt.Printf("🗑️ 移除监听地址: chain=%s, address=%s\n", chain, address)
return nil
} else {
fmt.Printf("⚠️ 链未注册: %s\n", chain)
return fmt.Errorf("⚠️ 链未注册: %s\n", chain)
}
}