(op Operation)
| 398 | } |
| 399 | |
| 400 | func (self *diff) enqueue(op Operation) (err error) { |
| 401 | switch op.Type { |
| 402 | case OpBlock: |
| 403 | if self.pending_op != nil { |
| 404 | switch self.pending_op.Type { |
| 405 | case OpBlock: |
| 406 | if self.pending_op.BlockIndex+1 == op.BlockIndex { |
| 407 | self.pending_op = &Operation{ |
| 408 | Type: OpBlockRange, |
| 409 | BlockIndex: self.pending_op.BlockIndex, |
| 410 | BlockIndexEnd: op.BlockIndex, |
| 411 | } |
| 412 | return |
| 413 | } |
| 414 | case OpBlockRange: |
| 415 | if self.pending_op.BlockIndexEnd+1 == op.BlockIndex { |
| 416 | self.pending_op.BlockIndexEnd = op.BlockIndex |
| 417 | return |
| 418 | } |
| 419 | } |
| 420 | if err = self.send_pending(); err != nil { |
| 421 | return err |
| 422 | } |
| 423 | } |
| 424 | self.pending_op = &op |
| 425 | case OpHash: |
| 426 | if err = self.send_pending(); err != nil { |
| 427 | return |
| 428 | } |
| 429 | if err = self.send_op(&op); err != nil { |
| 430 | return |
| 431 | } |
| 432 | } |
| 433 | return |
| 434 | |
| 435 | } |
| 436 | |
| 437 | func (self *diff) send_op(op *Operation) error { |
| 438 | b := self.op_write_buf[:op.SerializeSize()] |
no test coverage detected