(buf *bytes.Buffer, pr *pb.Proposal, pending map[uint64]bool)
| 821 | } |
| 822 | |
| 823 | func printAlphaProposal(buf *bytes.Buffer, pr *pb.Proposal, pending map[uint64]bool) { |
| 824 | if pr == nil { |
| 825 | return |
| 826 | } |
| 827 | |
| 828 | switch { |
| 829 | case pr.Mutations != nil: |
| 830 | fmt.Fprintf(buf, " Mutation . StartTs: %d . Edges: %d .", |
| 831 | pr.Mutations.StartTs, len(pr.Mutations.Edges)) |
| 832 | if len(pr.Mutations.Edges) > 0 { |
| 833 | pending[pr.Mutations.StartTs] = true |
| 834 | } else { |
| 835 | fmt.Fprintf(buf, " Mutation: %+v .", pr.Mutations) |
| 836 | } |
| 837 | fmt.Fprintf(buf, " Pending txns: %d .", len(pending)) |
| 838 | case len(pr.Kv) > 0: |
| 839 | fmt.Fprintf(buf, " KV . Size: %d ", len(pr.Kv)) |
| 840 | case pr.State != nil: |
| 841 | fmt.Fprintf(buf, " State . %+v ", pr.State) |
| 842 | case pr.Delta != nil: |
| 843 | fmt.Fprintf(buf, " Delta .") |
| 844 | sort.Slice(pr.Delta.Txns, func(i, j int) bool { |
| 845 | ti := pr.Delta.Txns[i] |
| 846 | tj := pr.Delta.Txns[j] |
| 847 | return ti.StartTs < tj.StartTs |
| 848 | }) |
| 849 | fmt.Fprintf(buf, " Max: %d .", pr.Delta.GetMaxAssigned()) |
| 850 | for _, txn := range pr.Delta.Txns { |
| 851 | delete(pending, txn.StartTs) |
| 852 | } |
| 853 | // There could be many thousands of txns within a single delta. We |
| 854 | // don't need to print out every single entry, so just show the |
| 855 | // first 10. |
| 856 | if len(pr.Delta.Txns) >= 10 { |
| 857 | fmt.Fprintf(buf, " Num txns: %d .", len(pr.Delta.Txns)) |
| 858 | pr.Delta.Txns = pr.Delta.Txns[:10] |
| 859 | } |
| 860 | for _, txn := range pr.Delta.Txns { |
| 861 | fmt.Fprintf(buf, " %d → %d .", txn.StartTs, txn.CommitTs) |
| 862 | } |
| 863 | fmt.Fprintf(buf, " Pending txns: %d .", len(pending)) |
| 864 | case pr.Snapshot != nil: |
| 865 | fmt.Fprintf(buf, " Snapshot . %+v ", pr.Snapshot) |
| 866 | } |
| 867 | } |
| 868 | |
| 869 | func printZeroProposal(buf *bytes.Buffer, zpr *pb.ZeroProposal) { |
| 870 | if zpr == nil { |
no test coverage detected