Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

En 6847 timestamp in p2p message #2023

Merged
merged 10 commits into from Jun 27, 2020

Conversation

iulianpascalau
Copy link
Contributor

  • added timestamp on each and every p2p message.go
  • added extra protection for all peers to follow the message protocol

@iulianpascalau iulianpascalau self-assigned this Jun 25, 2020
@iulianpascalau iulianpascalau added the type:feature New feature or request label Jun 25, 2020
@sasurobert sasurobert self-requested a review June 25, 2020 17:46
Base automatically changed from peer-honesty-implementation to development June 26, 2020 14:43
# 0 disables the feature.
[Marshalizer]
Type = "gogo protobuf"
SizeCheckDelta = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

p2pConfigurationFile = "./config/p2p.toml"

// ErrMarshalizerCreation signals that the marshalizer cannot be created based on provided data
ErrMarshalizerCreation = errors.New("error creating marshalizer")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this define - just create the error where it is needed. it is in main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import "github.com/gogo/protobuf/gogoproto/gogo.proto";

message TopicMessage{
bytes Payload = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

var ErrNilCacher = errors.New("nil cacher")
// ErrMessageUnmarshalError signals that an invalid message was received from a peer. There is no way to communicate
// with such a peer as it does not respect the protocol
var ErrMessageUnmarshalError = errors.New("message unmarshal error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line to end of file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an empty line there

"github.com/ElrondNetwork/elrond-go/p2p/message"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-pubsub"
)

// NewMessage returns a new instance of a Message object
func NewMessage(msg *pubsub.Message) (*message.Message, error) {
func NewMessage(msg *pubsub.Message, marshalizer p2p.Marshalizer) (*message.Message, error) {
if marshalizer == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chekc.ifnil with reflection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better, check.IfNil()

SeqNoField: msg.Seqno,
TopicsField: msg.TopicIDs,
SignatureField: msg.Signature,
KeyField: msg.Key,
}

var err error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for var err error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Usage: "The `" + filePathPlaceholder + "` for the main configuration file. This TOML file contain the main " +
"configurations such as the marshalizer type",
Value: "./config/config.toml",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have an option for a custom configuration file before this?

Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System tests passed.

@iulianpascalau iulianpascalau merged commit dc0181f into development Jun 27, 2020
@iulianpascalau iulianpascalau deleted the EN-6847-timestamp-in-p2p-message branch June 27, 2020 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants