Merge pull request #1709 from nspcc-dev/network-fixes-for-preview5

Network fixes for preview5
This commit is contained in:
Roman Khimov 2021-02-05 16:22:00 +03:00 committed by GitHub
commit d138ed731c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -1,5 +1,5 @@
ProtocolConfiguration:
Magic: 1951352142
Magic: 894448462
MaxTraceableBlocks: 2102400
SecondsPerBlock: 15
MemPoolSize: 50000

View file

@ -86,6 +86,7 @@ type (
transactions chan *transaction.Transaction
consensusStarted *atomic.Bool
canHandleExtens *atomic.Bool
oracle *oracle.Oracle
@ -131,6 +132,7 @@ func newServerFromConstructors(config ServerConfig, chain blockchainer.Blockchai
unregister: make(chan peerDrop),
peers: make(map[Peer]bool),
consensusStarted: atomic.NewBool(false),
canHandleExtens: atomic.NewBool(false),
extensiblePool: extpool.New(chain),
log: log,
transactions: make(chan *transaction.Transaction, 64),
@ -786,6 +788,12 @@ func (s *Server) handleGetHeadersCmd(p Peer, gh *payload.GetBlockByIndex) error
// handleExtensibleCmd processes received extensible payload.
func (s *Server) handleExtensibleCmd(e *payload.Extensible) error {
if !s.canHandleExtens.Load() {
if !s.IsInSync() {
return nil
}
s.canHandleExtens.Store(true)
}
ok, err := s.extensiblePool.Add(e)
if err != nil {
return err
@ -796,6 +804,7 @@ func (s *Server) handleExtensibleCmd(e *payload.Extensible) error {
switch e.Category {
case consensus.Category:
s.consensus.OnPayload(e)
case "StateService": // no-op for now
default:
return errors.New("invalid category")
}