From 9860e75cb4037989304187b4af543dacf5a6e312 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 19 Feb 2016 01:18:31 +0100 Subject: [PATCH] p2p: avoid calling os.Getenv for every handshake --- p2p/rlpx.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/p2p/rlpx.go b/p2p/rlpx.go index feab20ba8d..9d6cba5b67 100644 --- a/p2p/rlpx.go +++ b/p2p/rlpx.go @@ -262,6 +262,8 @@ func (h *encHandshake) staticSharedSecret(prv *ecdsa.PrivateKey) ([]byte, error) return ecies.ImportECDSA(prv).GenerateShared(h.remotePub, sskLen, sskLen) } +var configSendEIP = os.Getenv("RLPX_EIP8") != "" + // initiatorEncHandshake negotiates a session token on conn. // it should be called on the dialing side of the connection. // @@ -273,7 +275,7 @@ func initiatorEncHandshake(conn io.ReadWriter, prv *ecdsa.PrivateKey, remoteID d return s, err } var authPacket []byte - if os.Getenv("RLPX_EIP8") != "" { + if configSendEIP { authPacket, err = sealEIP8(authMsg, h) } else { authPacket, err = authMsg.sealPlain(h)