mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
network: fix requestTx()
2 bugs were here: 1. If amount of tx is small, no messages were sent. 2. Correctly cut byte slice if last message is small.
This commit is contained in:
parent
363c24d128
commit
ee45d7739f
1 changed files with 5 additions and 2 deletions
|
@ -887,12 +887,15 @@ func (s *Server) requestTx(hashes ...util.Uint256) {
|
|||
return
|
||||
}
|
||||
|
||||
for i := 0; i < len(hashes)/payload.MaxHashesCount; i++ {
|
||||
for i := 0; i <= len(hashes)/payload.MaxHashesCount; i++ {
|
||||
start := i * payload.MaxHashesCount
|
||||
stop := (i + 1) * payload.MaxHashesCount
|
||||
if stop < len(hashes) {
|
||||
if stop > len(hashes) {
|
||||
stop = len(hashes)
|
||||
}
|
||||
if start == stop {
|
||||
break
|
||||
}
|
||||
msg := s.MkMsg(CMDGetData, payload.NewInventory(payload.TXType, hashes[start:stop]))
|
||||
// It's high priority because it directly affects consensus process,
|
||||
// even though it's getdata.
|
||||
|
|
Loading…
Reference in a new issue