Conversation
| func (e DataEntries) String() string { | ||
| var resStr string | ||
| for _, entry := range e { | ||
| entryStr := entry.GetKey() + entry.GetValueType().String() |
There was a problem hiding this comment.
No divider between key and value?
| } | ||
|
|
||
| // SortDataEntries sorts DataEntries slice by entry keys. | ||
| func SortDataEntries(entries []DataEntry) { |
There was a problem hiding this comment.
I think this function can be package private. Or, it can be declared as a method of DataEntries slice
| } | ||
|
|
||
| func (e DataEntries) String() string { | ||
| var resStr string |
There was a problem hiding this comment.
It's better to use stings.Builder for concatenating many strings.
| return true, nil | ||
| } | ||
|
|
||
| func SortAtomicSnapshotsByType(snapshots TxSnapshot) { |
There was a problem hiding this comment.
I think this function can be package private. Or, it can be declared as a method of TxSnapshot slice. And, is it really necessary to create function when the type implements sort.Interface?
| return entry, nil | ||
| } | ||
|
|
||
| func CompareDataEntry(a, b DataEntry) bool { |
There was a problem hiding this comment.
Is it necessary to create such function? i think you can use the same approach as for AtomicSnapshots. Create Equal method for each DataEntry type and use the new method for comparison.
| addr2, _ := proto.NewAddressFromString("3P9o3uwx3fWZz3b5aaaaaaaaaaFoPW6z7HB") | ||
| assetID1 := crypto.MustDigestFromBase58("BrjV5AB5S7qN5tLQFbU5tpLj5qeozfVvPxEpDkmmhNP") | ||
| assetID2 := crypto.MustDigestFromBase58("5Zv8JLH8TTvq9iCo6HtB2K7CGpTJt6JTj5yvXaDVrxEJ") | ||
| publicKey1, _ := crypto.NewPublicKeyFromBase58("5TBjL2VdL1XmXq5dC4SYMeH5sVCGmMTeBNNYqWCuEXMn") |
| if err != nil { | ||
| t.Errorf("Error comparing snapshots: %v", err) | ||
| } | ||
| if equal != tt.wantEqual { | ||
| t.Errorf("Expected snapshots to be equal: %v, got: %v", tt.wantEqual, equal) | ||
| } |
There was a problem hiding this comment.
You can use testify package.
| } | ||
|
|
||
| // Equal compares two DataEntries slices and returns true if they are equal. | ||
| func (e DataEntries) Equal(other DataEntries) (bool, error) { |
There was a problem hiding this comment.
It's necessary to say that this function mutates passed argument, i.e. elements order in the slice.
|
|
||
| func (s DataEntriesSnapshot) Apply(a SnapshotApplier) error { return a.ApplyDataEntries(s) } | ||
|
|
||
| func (s DataEntriesSnapshot) Equal(otherSnapshot AtomicSnapshot) (bool, error) { |
There was a problem hiding this comment.
It's necessary to say that this function mutates passed argument, i.e. elements order in theDataEntries slice.
| } | ||
|
|
||
| // Equal function assumes that TransactionsSnapshots are in same order in both original and other instances. | ||
| func (bs BlockSnapshot) Equal(other BlockSnapshot) (bool, error) { |
There was a problem hiding this comment.
It's necessary to say that this function can mutate the passed argument
No description provided.