Skip to content

Commit

Permalink
Clean up log messages, gossip state transfer
Browse files Browse the repository at this point in the history
Removing all decorating symbols from logging printouts.

Change-Id: I5d0aac68544df8918cbaacfd78ab3947b562a5ab
Signed-off-by: Artem Barger <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Feb 9, 2017
1 parent 4e051ed commit 728519c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
12 changes: 6 additions & 6 deletions gossip/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
// capable to full fill missing blocks by running state replication and
// sending request to get missing block to other nodes
type GossipStateProvider interface {

// Retrieve block with sequence number equal to index
GetBlock(index uint64) *common.Block

Expand Down Expand Up @@ -174,7 +173,7 @@ func (s *GossipStateProviderImpl) listen() {
break next
}
}
s.logger.Debug("[XXX]: Stop listening for new messages")
s.logger.Debug("Stop listening for new messages")
s.done.Done()
}

Expand Down Expand Up @@ -288,7 +287,7 @@ func (s *GossipStateProviderImpl) deliverPayloads() {
for payload := s.payloads.Pop(); payload != nil; payload = s.payloads.Pop() {
rawblock := &common.Block{}
if err := pb.Unmarshal(payload.Data, rawblock); err != nil {
s.logger.Errorf("Error getting block with seqNum = %d due to (%s)...dropping block\n", payload.SeqNum, err)
s.logger.Errorf("Error getting block with seqNum = %d due to (%s)...dropping block", payload.SeqNum, err)
continue
}
s.logger.Debug("New block with sequence number ", payload.SeqNum, " transactions num ", len(rawblock.Data.Data))
Expand Down Expand Up @@ -331,6 +330,7 @@ func (s *GossipStateProviderImpl) antiEntropy() {

s.requestBlocksInRange(uint64(current), uint64(max))
}
s.logger.Debug("Stateprovider stopped, stopping anti entropy procedure.")
s.done.Done()
}

Expand Down Expand Up @@ -367,7 +367,7 @@ func (s *GossipStateProviderImpl) requestBlocksInRange(start uint64, end uint64)
request.SeqNums = append(request.SeqNums, uint64(i))
}

s.logger.Debug("[$$$$$$$$$$$$$$$$]: Sending direct request to complete missing blocks, ", request, "for chain", s.chainID)
s.logger.Debug("Sending direct request to complete missing blocks,", request, "for chain", s.chainID)
s.gossip.Send(&proto.GossipMessage{
Nonce: 0,
Tag: proto.GossipMessage_CHAN_OR_ORG,
Expand Down Expand Up @@ -395,7 +395,7 @@ func (s *GossipStateProviderImpl) AddPayload(payload *proto.Payload) error {

func (s *GossipStateProviderImpl) commitBlock(block *common.Block, seqNum uint64) error {
if err := s.committer.Commit(block); err != nil {
s.logger.Errorf("Got error while committing(%s)\n", err)
s.logger.Errorf("Got error while committing(%s)", err)
return err
}

Expand All @@ -409,6 +409,6 @@ func (s *GossipStateProviderImpl) commitBlock(block *common.Block, seqNum uint64
s.logger.Errorf("Unable to serialize node meta state, error = %s", err)
}

s.logger.Debug("[XXX]: Commit success, created a block!")
s.logger.Debug("Commit success, created a block!")
return nil
}
19 changes: 9 additions & 10 deletions gossip/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,25 +324,24 @@ func TestNewGossipStateProvider_SendingManyMessages(t *testing.T) {
waitUntilTrueOrTimeout(t, func() bool {
for _, p := range peersSet {
if len(p.g.PeersOfChannel(common.ChainID(util.GetTestChainID()))) != bootstrapSetSize+standartPeersSize-1 {
logger.Debug("[XXXXXXX]: Peer discovery has not finished yet")
logger.Debug("Peer discovery has not finished yet")
return false
}
}
logger.Debug("[AAAAAA]: All peer discovered each other!!!")
logger.Debug("All peer discovered each other!!!")
return true
}, 30*time.Second)

logger.Debug("[!!!!!]: Waiting for all blocks to arrive.")
logger.Debug("Waiting for all blocks to arrive.")
waitUntilTrueOrTimeout(t, func() bool {
logger.Debug("[*****]: Trying to see all peers get all blocks")
logger.Debug("Trying to see all peers get all blocks")
for _, p := range peersSet {
height, err := p.commit.LedgerHeight()
if height != uint64(msgCount+1) || err != nil {
//logger.Debug("[XXXXXXX]: Ledger height is at: ", height)
return false
}
}
logger.Debug("[#####]: All peers have same ledger height!!!")
logger.Debug("All peers have same ledger height!!!")
return true
}, 60*time.Second)
}
Expand Down Expand Up @@ -401,7 +400,7 @@ func TestGossipStateProvider_TestStateMessages(t *testing.T) {
select {
case <-readyCh:
{
logger.Info("[XXX]: Done!!!")
logger.Info("Done!!!")

}
case <-time.After(time.Duration(10) * time.Second):
Expand All @@ -414,12 +413,12 @@ func TestGossipStateProvider_TestStateMessages(t *testing.T) {
func waitUntilTrueOrTimeout(t *testing.T, predicate func() bool, timeout time.Duration) {
ch := make(chan struct{})
go func() {
logger.Debug("[@@@@@]: Started to spin off, until predicate will be satisfied.")
logger.Debug("Started to spin off, until predicate will be satisfied.")
for !predicate() {
time.Sleep(1 * time.Second)
}
ch <- struct{}{}
logger.Debug("[@@@@@]: Done.")
logger.Debug("Done.")
}()

select {
Expand All @@ -429,5 +428,5 @@ func waitUntilTrueOrTimeout(t *testing.T, predicate func() bool, timeout time.Du
t.Fatal("Timeout has expired")
break
}
logger.Debug("[>>>>>] Stop wainting until timeout or true")
logger.Debug("Stop waiting until timeout or true")
}

0 comments on commit 728519c

Please sign in to comment.