forked from bnb-chain/bsc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增SignTx && 心跳检测 && Tx查询上报 (bnb-chain#5)
* 新增本地记录所有Peer Encode ID功能 * sign * tx上报 * tx * 使用gorm * 钉钉上报 * 更新格式 * 更新格式 * 自动读取ipc地址 * 新增手动添加Peer方法 && 修复Sign循环错误 * 新增修改自动签次数Redis事件 * 自动广播Tx * 数量 * 新增Arb心跳检测 * 新增公网Redis * 新增SignTx && 心跳检测 && Tx查询上报
- Loading branch information
Showing
9 changed files
with
179 additions
and
86 deletions.
There are no files selected for viewing
Submodule arb
updated
from 5bd644 to 5e05a1
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package eth | ||
|
||
import ( | ||
"errors" | ||
"github.com/ethereum/go-ethereum/log" | ||
"sync" | ||
) | ||
|
||
type peerManager struct { | ||
//nodeID:encodeID | ||
peers map[string]string // all peers , including removed peer | ||
} | ||
|
||
var instance *peerManager | ||
var once sync.Once | ||
|
||
func GetPeerManagerInstance() *peerManager { | ||
once.Do(func() { | ||
instance = &peerManager{ | ||
peers: make(map[string]string), | ||
} | ||
}) | ||
return instance | ||
} | ||
|
||
func (p *peerManager) savePeerInfo(peer *Peer) { | ||
if _, foundedPeer := p.peers[peer.ID()]; !foundedPeer { | ||
//储存Peer信息 | ||
p.peers[peer.ID()] = peer.Peer.Node().URLv4() | ||
log.Debug("Save Peer Info", peer.Peer.Node().URLv4()) | ||
} | ||
} | ||
|
||
func (p *peerManager) fetchPeerEncodeID(peerID string) (string, error) { | ||
if _, foundedPeer := p.peers[peerID]; !foundedPeer { | ||
return "", errors.New("not found PeerID Info") | ||
} | ||
return p.peers[peerID], nil | ||
} |
Oops, something went wrong.