forked from TrueCloudLab/neoneo-go
[server]
- modified server to pass the syncmgr the lastBlock.Index+1 so that syncmgr knows what blockIndex it should be looking for upon initialisation
This commit is contained in:
parent
751d2711d4
commit
68b0e2e3f2
2 changed files with 14 additions and 3 deletions
|
@ -56,7 +56,10 @@ func New(net protocol.Magic, port uint16) (*Server, error) {
|
||||||
s.chain = chain
|
s.chain = chain
|
||||||
|
|
||||||
// Setup sync manager
|
// Setup sync manager
|
||||||
syncmgr := setupSyncManager(s)
|
syncmgr, err := setupSyncManager(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
s.smg = syncmgr
|
s.smg = syncmgr
|
||||||
|
|
||||||
// Setup connection manager
|
// Setup connection manager
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/CityOfZion/neo-go/pkg/wire/util"
|
"github.com/CityOfZion/neo-go/pkg/wire/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupSyncManager(s *Server) *syncmgr.Syncmgr {
|
func setupSyncManager(s *Server) (*syncmgr.Syncmgr, error) {
|
||||||
|
|
||||||
cfg := &syncmgr.Config{
|
cfg := &syncmgr.Config{
|
||||||
ProcessBlock: s.processBlock,
|
ProcessBlock: s.processBlock,
|
||||||
|
@ -27,7 +27,15 @@ func setupSyncManager(s *Server) *syncmgr.Syncmgr {
|
||||||
FetchBlockAgain: s.fetchBlockAgain,
|
FetchBlockAgain: s.fetchBlockAgain,
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncmgr.New(cfg)
|
// Add nextBlockIndex in syncmgr
|
||||||
|
lastBlock, err := s.chain.Db.GetLastBlock()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
nextBlockIndex := lastBlock.Index + 1
|
||||||
|
|
||||||
|
return syncmgr.New(cfg, nextBlockIndex), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) onHeader(peer *peer.Peer, hdrsMessage *payload.HeadersMessage) {
|
func (s *Server) onHeader(peer *peer.Peer, hdrsMessage *payload.HeadersMessage) {
|
||||||
|
|
Loading…
Reference in a new issue