Skip to content

Commit e4fe035

Browse files
authored
Update Comm Method Names (#181)
* update comm methods * update name * Update README.md Signed-off-by: Sam Liokumovich <65994425+samliok@users.noreply.github.com> --------- Signed-off-by: Sam Liokumovich <65994425+samliok@users.noreply.github.com>
1 parent d33ae6a commit e4fe035

File tree

7 files changed

+26
-32
lines changed

7 files changed

+26
-32
lines changed

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,11 @@ which also can be configured on an epoch basis, is defined:
507507
```go
508508
type Communication interface {
509509

510-
// ListNodes returns all nodes known to the application.
511-
ListNodes() []NodeID
510+
// Nodes returns all nodes known to the application.
511+
Nodes() []NodeID
512512

513-
// SendMessage sends a message to the given destination node
514-
SendMessage(msg Message, destination NodeID)
513+
// Send sends a message to the given destination node
514+
Send(msg Message, destination NodeID)
515515

516516
// Broadcast broadcasts the given message to all nodes
517517
Broadcast(msg Message)
@@ -721,9 +721,3 @@ BlockResponse {
721721
block Block
722722
}
723723
```
724-
725-
726-
727-
728-
729-

api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ type Storage interface {
5454

5555
type Communication interface {
5656

57-
// ListNodes returns all nodes known to the application.
58-
ListNodes() []NodeID
57+
// Nodes returns all nodes known to the application.
58+
Nodes() []NodeID
5959

60-
// SendMessage sends a message to the given destination node
61-
SendMessage(msg *Message, destination NodeID)
60+
// Send sends a message to the given destination node
61+
Send(msg *Message, destination NodeID)
6262

6363
// Broadcast broadcasts the given message to all nodes.
6464
// Does not send it to yourself.

epoch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (e *Epoch) init() error {
173173
e.monitor = NewMonitor(e.StartTime, e.Logger)
174174
e.cancelWaitForBlockNotarization = func() {}
175175
e.finishCtx, e.finishFn = context.WithCancel(context.Background())
176-
e.nodes = e.Comm.ListNodes()
176+
e.nodes = e.Comm.Nodes()
177177
e.quorumSize = Quorum(len(e.nodes))
178178
e.rounds = make(map[uint64]*Round)
179179
e.maxRoundWindow = DefaultMaxRoundWindow
@@ -706,7 +706,7 @@ func (e *Epoch) maybeSendNotarizationOrFinalization(to NodeID, round uint64) {
706706
msg := &Message{
707707
Finalization: r.finalization,
708708
}
709-
e.Comm.SendMessage(msg, to)
709+
e.Comm.Send(msg, to)
710710
return
711711
}
712712

@@ -715,7 +715,7 @@ func (e *Epoch) maybeSendNotarizationOrFinalization(to NodeID, round uint64) {
715715
msg := &Message{
716716
Notarization: r.notarization,
717717
}
718-
e.Comm.SendMessage(msg, to)
718+
e.Comm.Send(msg, to)
719719
return
720720
}
721721
}
@@ -2422,7 +2422,7 @@ func (e *Epoch) handleReplicationRequest(req *ReplicationRequest, from NodeID) e
24222422

24232423
response.Data = data
24242424
msg := &Message{VerifiedReplicationResponse: response}
2425-
e.Comm.SendMessage(msg, from)
2425+
e.Comm.Send(msg, from)
24262426
return nil
24272427
}
24282428

epoch_failover_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,11 @@ func newRebroadcastComm(nodes []NodeID) *rebroadcastComm {
780780
}
781781
}
782782

783-
func (r *rebroadcastComm) ListNodes() []NodeID {
783+
func (r *rebroadcastComm) Nodes() []NodeID {
784784
return r.nodes
785785
}
786786

787-
func (r *rebroadcastComm) SendMessage(*Message, NodeID) {
787+
func (r *rebroadcastComm) Send(*Message, NodeID) {
788788

789789
}
790790

@@ -887,7 +887,7 @@ func runCrashAndRestartExecution(t *testing.T, e *Epoch, bb *testBlockBuilder, w
887887
cloneWAL := wal.Clone()
888888
cloneStorage := storage.Clone()
889889

890-
nodes := e.Comm.ListNodes()
890+
nodes := e.Comm.Nodes()
891891

892892
// Clone the block builder
893893
bbAfterCrash := &testBlockBuilder{

epoch_multinode_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ func newTestComm(from NodeID, net *inMemNetwork, messageFilter messageFilter) *t
490490
}
491491
}
492492

493-
func (c *testComm) ListNodes() []NodeID {
493+
func (c *testComm) Nodes() []NodeID {
494494
return c.net.nodes
495495
}
496496

497-
func (c *testComm) SendMessage(msg *Message, destination NodeID) {
497+
func (c *testComm) Send(msg *Message, destination NodeID) {
498498
if !c.isMessagePermitted(msg, destination) {
499499
return
500500
}

epoch_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func TestEpochIndexFinalization(t *testing.T) {
151151
// when we receive that finalization, we should commit the rest of the finalizations for seqs
152152
// 1 & 2
153153

154-
finalization, _ := newFinalizationRecord(t, conf.Logger, conf.SignatureAggregator, firstBlock, e.Comm.ListNodes())
154+
finalization, _ := newFinalizationRecord(t, conf.Logger, conf.SignatureAggregator, firstBlock, e.Comm.Nodes())
155155
injectTestFinalization(t, e, &finalization, nodes[1])
156156

157157
storage.waitForBlockCommit(2)
@@ -523,10 +523,10 @@ func TestEpochStartedTwice(t *testing.T) {
523523
}
524524

525525
func advanceRoundFromEmpty(t *testing.T, e *Epoch) {
526-
leader := LeaderForRound(e.Comm.ListNodes(), e.Metadata().Round)
526+
leader := LeaderForRound(e.Comm.Nodes(), e.Metadata().Round)
527527
require.False(t, e.ID.Equals(leader), "epoch cannot be the leader for the empty round")
528528

529-
emptyNote := newEmptyNotarization(e.Comm.ListNodes(), e.Metadata().Round, e.Metadata().Seq)
529+
emptyNote := newEmptyNotarization(e.Comm.Nodes(), e.Metadata().Round, e.Metadata().Seq)
530530
err := e.HandleMessage(&Message{
531531
EmptyNotarization: emptyNote,
532532
}, leader)
@@ -555,7 +555,7 @@ func notarizeAndFinalizeRound(t *testing.T, e *Epoch, bb *testBlockBuilder) (Ver
555555
func advanceRound(t *testing.T, e *Epoch, bb *testBlockBuilder, notarize bool, finalize bool) (VerifiedBlock, *Notarization) {
556556
require.True(t, notarize || finalize, "must either notarize or finalize a round to advance")
557557
nextSeqToCommit := e.Storage.Height()
558-
nodes := e.Comm.ListNodes()
558+
nodes := e.Comm.Nodes()
559559
quorum := Quorum(len(nodes))
560560
// leader is the proposer of the new block for the given round
561561
leader := LeaderForRound(nodes, e.Metadata().Round)
@@ -1288,11 +1288,11 @@ func (t *testVerifier) Verify(_ []byte, _ []byte, _ NodeID) error {
12881288

12891289
type noopComm []NodeID
12901290

1291-
func (n noopComm) ListNodes() []NodeID {
1291+
func (n noopComm) Nodes() []NodeID {
12921292
return n
12931293
}
12941294

1295-
func (n noopComm) SendMessage(*Message, NodeID) {
1295+
func (n noopComm) Send(*Message, NodeID) {
12961296

12971297
}
12981298

@@ -1314,7 +1314,7 @@ func NewListenerComm(nodeIDs []NodeID) *listnerComm {
13141314
}
13151315
}
13161316

1317-
func (b *listnerComm) SendMessage(msg *Message, id NodeID) {
1317+
func (b *listnerComm) Send(msg *Message, id NodeID) {
13181318
b.in <- msg
13191319
}
13201320

replication.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func NewReplicationState(logger Logger, comm Communication, id NodeID, maxRoundW
6969
id: id,
7070
maxRoundWindow: maxRoundWindow,
7171
receivedQuorumRounds: make(map[uint64]QuorumRound),
72-
timeoutHandler: NewTimeoutHandler(logger, start, comm.ListNodes()),
72+
timeoutHandler: NewTimeoutHandler(logger, start, comm.Nodes()),
7373
}
7474
}
7575

@@ -152,7 +152,7 @@ func (r *ReplicationState) sendRequestToNode(start uint64, end uint64, nodes []N
152152

153153
r.timeoutHandler.AddTask(task)
154154

155-
r.comm.SendMessage(msg, nodes[index])
155+
r.comm.Send(msg, nodes[index])
156156
}
157157

158158
func (r *ReplicationState) createReplicationTimeoutTask(start, end uint64, nodes []NodeID, index int) *TimeoutTask {

0 commit comments

Comments
 (0)