diff --git a/blockheader.go b/blockheader.go index 9eb643e6..d04d83b3 100644 --- a/blockheader.go +++ b/blockheader.go @@ -89,11 +89,13 @@ func (h *BlockHeader) Serialize(w io.Writer) error { func NewBlockHeader(prevHash *ShaHash, merkleRootHash *ShaHash, bits uint32, nonce uint32) *BlockHeader { + // Limit the timestamp to one second precision since the protocol + // doesn't support better. return &BlockHeader{ Version: BlockVersion, PrevBlock: *prevHash, MerkleRoot: *merkleRootHash, - Timestamp: time.Now(), + Timestamp: time.Unix(time.Now().Unix(), 0), Bits: bits, Nonce: nonce, } diff --git a/msgversion.go b/msgversion.go index c8ac391b..6b215759 100644 --- a/msgversion.go +++ b/msgversion.go @@ -176,7 +176,7 @@ func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32 { func NewMsgVersion(me *NetAddress, you *NetAddress, nonce uint64, userAgent string, lastBlock int32) *MsgVersion { - // Limit the Timestamp to millisecond precision since the protocol + // Limit the timestamp to one second precision since the protocol // doesn't support better. return &MsgVersion{ ProtocolVersion: int32(ProtocolVersion), diff --git a/netaddress.go b/netaddress.go index 8d060f8e..f4017111 100644 --- a/netaddress.go +++ b/netaddress.go @@ -75,8 +75,10 @@ func (na *NetAddress) SetAddress(ip net.IP, port uint16) { // NewNetAddressIPPort returns a new NetAddress using the provided IP, port, and // supported services with defaults for the remaining fields. func NewNetAddressIPPort(ip net.IP, port uint16, services ServiceFlag) *NetAddress { + // Limit the timestamp to one second precision since the protocol + // doesn't support better. na := NetAddress{ - Timestamp: time.Now(), + Timestamp: time.Unix(time.Now().Unix(), 0), Services: services, IP: ip, Port: port,