Skip to content

Commit

Permalink
Merge "Fix golint warning for gossip state package"
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinivasan Muralidharan authored and Gerrit Code Review committed Dec 7, 2016
2 parents 703df8e + 1b5dfb3 commit 5c9fcc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gossip/state/metastate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ import (
"encoding/binary"
)

// Metadata information to store the information about current
// NodeMetastate information to store the information about current
// height of the ledger (last accepted block sequence number).
type NodeMetastate struct {

// Actual ledger height
LedgerHeight uint64
}

// Create new meta data with given ledger height148.69
// NewNodeMetastate creates new meta data with given ledger height148.69
func NewNodeMetastate(height uint64) *NodeMetastate {
return &NodeMetastate{height}
}

// Decodes meta state into byte array for serialization
// Bytes decodes meta state into byte array for serialization
func (n *NodeMetastate) Bytes() ([]byte, error) {
buffer := new(bytes.Buffer)
// Explicitly specify byte order for write into the buffer
Expand All @@ -47,7 +47,7 @@ func (n *NodeMetastate) Bytes() ([]byte, error) {
return buffer.Bytes(), nil
}

// Get ledger height from the state
// Height returns ledger height from the state
func (n *NodeMetastate) Height() uint64 {
return n.LedgerHeight
}
Expand All @@ -57,7 +57,7 @@ func (n *NodeMetastate) Update(height uint64) {
n.LedgerHeight = height
}

// Encode from byte array into meta data structure
// FromBytes - encode from byte array into meta data structure
func FromBytes(buf []byte) (*NodeMetastate, error) {
state := NodeMetastate{}
reader := bytes.NewReader(buf)
Expand Down
3 changes: 3 additions & 0 deletions gossip/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ func (s *GossipStateProviderImpl) requestBlocksInRange(start uint64, end uint64)
}, peer)
}


// GetBlock return ledger block given its sequence number as a parameter
func (s *GossipStateProviderImpl) GetBlock(index uint64) *common.Block {
// Try to read missing block from the ledger, should return no nil with
// content including at least one block
Expand All @@ -377,6 +379,7 @@ func (s *GossipStateProviderImpl) GetBlock(index uint64) *common.Block {
return nil
}

// AddPayload add new payload into state
func (s *GossipStateProviderImpl) AddPayload(payload *proto.Payload) error {
return s.payloads.Push(payload)
}
Expand Down

0 comments on commit 5c9fcc3

Please sign in to comment.