Next moves the iterator to the next key/value pair. It returns when the iterator is exhausted.
()
| 505 | // Next moves the iterator to the next key/value pair. |
| 506 | // It returns <nil, nil> when the iterator is exhausted. |
| 507 | func (scanner *RwsetScanner) Next() (*EndorserPvtSimulationResults, error) { |
| 508 | if !scanner.dbItr.Next() { |
| 509 | return nil, nil |
| 510 | } |
| 511 | dbKey := scanner.dbItr.Key() |
| 512 | dbVal := scanner.dbItr.Value() |
| 513 | _, blockHeight, err := splitCompositeKeyOfPvtRWSet(dbKey) |
| 514 | if err != nil { |
| 515 | return nil, err |
| 516 | } |
| 517 | |
| 518 | txPvtRWSet := &rwset.TxPvtReadWriteSet{} |
| 519 | txPvtRWSetWithConfig := &transientstore.TxPvtReadWriteSetWithConfigInfo{} |
| 520 | |
| 521 | var filteredTxPvtRWSet *rwset.TxPvtReadWriteSet |
| 522 | if dbVal[0] == nilByte { |
| 523 | // new proto, i.e., TxPvtReadWriteSetWithConfigInfo |
| 524 | if err := proto.Unmarshal(dbVal[1:], txPvtRWSetWithConfig); err != nil { |
| 525 | return nil, err |
| 526 | } |
| 527 | |
| 528 | // trim the tx rwset based on the current collection filter, |
| 529 | // nil will be returned to filteredTxPvtRWSet if the transient store txid entry does not contain the data for the collection |
| 530 | filteredTxPvtRWSet = trimPvtWSet(txPvtRWSetWithConfig.GetPvtRwset(), scanner.filter) |
| 531 | configs, err := trimPvtCollectionConfigs(txPvtRWSetWithConfig.CollectionConfigs, scanner.filter) |
| 532 | if err != nil { |
| 533 | return nil, err |
| 534 | } |
| 535 | txPvtRWSetWithConfig.CollectionConfigs = configs |
| 536 | } else { |
| 537 | // old proto, i.e., TxPvtReadWriteSet |
| 538 | if err := proto.Unmarshal(dbVal, txPvtRWSet); err != nil { |
| 539 | return nil, err |
| 540 | } |
| 541 | filteredTxPvtRWSet = trimPvtWSet(txPvtRWSet, scanner.filter) |
| 542 | } |
| 543 | |
| 544 | txPvtRWSetWithConfig.PvtRwset = filteredTxPvtRWSet |
| 545 | |
| 546 | return &EndorserPvtSimulationResults{ |
| 547 | ReceivedAtBlockHeight: blockHeight, |
| 548 | PvtSimulationResultsWithConfig: txPvtRWSetWithConfig, |
| 549 | }, nil |
| 550 | } |
| 551 | |
| 552 | // Close releases resource held by the iterator |
| 553 | func (scanner *RwsetScanner) Close() { |
nothing calls this directly
no test coverage detected