Skip to content

Commit

Permalink
Rename getMessagesForBlockHash to messages
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed May 4, 2022
1 parent e484a08 commit 8a4d2d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/grandpa/message_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (t *tracker) handleBlock(b *types.Block) {
defer t.mapLock.Unlock()

h := b.Header.Hash()
vms := t.votes.getMessagesForBlockHash(h)
vms := t.votes.messages(h)
for _, v := range vms {
// handleMessage would never error for vote message
_, err := t.handler.handleMessage(v.from, v.msg)
Expand Down
6 changes: 3 additions & 3 deletions lib/grandpa/message_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestMessageTracker_MapInsideMap(t *testing.T) {
}

hash := header.Hash()
messages := gs.tracker.votes.getMessagesForBlockHash(hash)
messages := gs.tracker.votes.messages(hash)
require.Empty(t, messages)

gs.keypair = kr.Alice().(*ed25519.Keypair)
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestMessageTracker_handleTick(t *testing.T) {
}

// shouldn't be deleted as round in message >= grandpa round
require.Len(t, gs.tracker.votes.getMessagesForBlockHash(testHash), 1)
require.Len(t, gs.tracker.votes.messages(testHash), 1)

gs.state.round = 1
msg = &VoteMessage{
Expand All @@ -238,5 +238,5 @@ func TestMessageTracker_handleTick(t *testing.T) {
}

// should be deleted as round in message < grandpa round
require.Empty(t, gs.tracker.votes.getMessagesForBlockHash(testHash))
require.Empty(t, gs.tracker.votes.messages(testHash))
}
6 changes: 3 additions & 3 deletions lib/grandpa/votes_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ func (vt *votesTracker) delete(blockHash common.Hash) {
delete(vt.mapping, blockHash)
}

// getMessagesForBlockHash returns all the vote messages
// messages returns all the vote messages
// for a particular block hash from the tracker as a slice
// of networkVoteMessage. There is no order in the slice.
// It returns nil if the block hash does not exist.
func (vt *votesTracker) getMessagesForBlockHash(
blockHash common.Hash) (messages []networkVoteMessage) {
func (vt *votesTracker) messages(blockHash common.Hash) (
messages []networkVoteMessage) {
authIDToData, ok := vt.mapping[blockHash]
if !ok {
// Note authIDToData cannot be empty
Expand Down
4 changes: 2 additions & 2 deletions lib/grandpa/votes_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func Test_votesTracker_delete(t *testing.T) {
})
}

func Test_votesTracker_getMessagesForBlockHash(t *testing.T) {
func Test_votesTracker_messages(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
Expand Down Expand Up @@ -306,7 +306,7 @@ func Test_votesTracker_getMessagesForBlockHash(t *testing.T) {
t.Parallel()

vt := testCase.votesTracker
messages := vt.getMessagesForBlockHash(testCase.blockHash)
messages := vt.messages(testCase.blockHash)

sort.Slice(messages, func(i, j int) bool {
if messages[i].from == messages[j].from {
Expand Down

0 comments on commit 8a4d2d3

Please sign in to comment.