mirror of https://github.com/status-im/go-waku.git
revert: utils.GetUnixEpoch()
This commit is contained in:
parent
051634c12a
commit
c1bdead94d
|
@ -15,6 +15,7 @@ import (
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
"github.com/status-im/go-waku/waku/v2/node"
|
"github.com/status-im/go-waku/waku/v2/node"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("basic2")
|
var log = logging.Logger("basic2")
|
||||||
|
@ -77,7 +78,7 @@ func randomHex(n int) (string, error) {
|
||||||
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
||||||
var contentTopic string = "test"
|
var contentTopic string = "test"
|
||||||
var version uint32 = 0
|
var version uint32 = 0
|
||||||
var timestamp float64 = float64(time.Now().Unix())
|
var timestamp float64 = utils.GetUnixEpoch()
|
||||||
|
|
||||||
p := new(node.Payload)
|
p := new(node.Payload)
|
||||||
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/filter"
|
"github.com/status-im/go-waku/waku/v2/protocol/filter"
|
||||||
wpb "github.com/status-im/go-waku/waku/v2/protocol/pb"
|
wpb "github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
||||||
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ func (cr *Chat) Publish(ctx context.Context, message string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var version uint32
|
var version uint32
|
||||||
var timestamp float64 = float64(time.Now().Unix())
|
var timestamp float64 = utils.GetUnixEpoch()
|
||||||
var keyInfo *node.KeyInfo = &node.KeyInfo{}
|
var keyInfo *node.KeyInfo = &node.KeyInfo{}
|
||||||
|
|
||||||
if cr.useV1Payload { // Use WakuV1 encryption
|
if cr.useV1Payload { // Use WakuV1 encryption
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/filter"
|
"github.com/status-im/go-waku/waku/v2/protocol/filter"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
||||||
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("filter2")
|
var log = logging.Logger("filter2")
|
||||||
|
@ -125,7 +126,7 @@ func randomHex(n int) (string, error) {
|
||||||
|
|
||||||
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
||||||
var version uint32 = 0
|
var version uint32 = 0
|
||||||
var timestamp float64 = float64(time.Now().UnixNano())
|
var timestamp float64 = utils.GetUnixEpoch()
|
||||||
|
|
||||||
p := new(node.Payload)
|
p := new(node.Payload)
|
||||||
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/status-im/go-waku/waku/v2/node"
|
"github.com/status-im/go-waku/waku/v2/node"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
"github.com/status-im/go-waku/waku/v2/protocol/relay"
|
||||||
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
//"github.com/status-im/go-waku/waku/v2/protocol/store"
|
//"github.com/status-im/go-waku/waku/v2/protocol/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ func randomHex(n int) (string, error) {
|
||||||
|
|
||||||
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) {
|
||||||
var version uint32 = 0
|
var version uint32 = 0
|
||||||
var timestamp float64 = float64(time.Now().Unix())
|
var timestamp float64 = utils.GetUnixEpoch()
|
||||||
|
|
||||||
p := new(node.Payload)
|
p := new(node.Payload)
|
||||||
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
||||||
|
|
|
@ -6,13 +6,13 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/status-im/go-waku/waku/v2/node"
|
"github.com/status-im/go-waku/waku/v2/node"
|
||||||
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
"github.com/status-im/go-waku/waku/v2/protocol/pb"
|
||||||
|
"github.com/status-im/go-waku/waku/v2/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicSendingReceiving(t *testing.T) {
|
func TestBasicSendingReceiving(t *testing.T) {
|
||||||
|
@ -61,7 +61,7 @@ func randomHex(n int) (string, error) {
|
||||||
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) error {
|
func write(ctx context.Context, wakuNode *node.WakuNode, msgContent string) error {
|
||||||
var contentTopic string = "test"
|
var contentTopic string = "test"
|
||||||
var version uint32 = 0
|
var version uint32 = 0
|
||||||
var timestamp float64 = float64(time.Now().Unix())
|
var timestamp float64 = utils.GetUnixEpoch()
|
||||||
|
|
||||||
p := new(node.Payload)
|
p := new(node.Payload)
|
||||||
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
p.Data = []byte(wakuNode.ID() + ": " + msgContent)
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
|
@ -360,7 +359,7 @@ func computeIndex(msg *pb.WakuMessage) (*pb.Index, error) {
|
||||||
digest := sha256.Sum256(data)
|
digest := sha256.Sum256(data)
|
||||||
return &pb.Index{
|
return &pb.Index{
|
||||||
Digest: digest[:],
|
Digest: digest[:],
|
||||||
ReceiverTime: float64(time.Now().Unix()),
|
ReceiverTime: utils.GetUnixEpoch(),
|
||||||
SenderTime: msg.Timestamp,
|
SenderTime: msg.Timestamp,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -575,7 +574,7 @@ func (store *WakuStore) findLastSeen() float64 {
|
||||||
// the resume proc returns the number of retrieved messages if no error occurs, otherwise returns the error string
|
// the resume proc returns the number of retrieved messages if no error occurs, otherwise returns the error string
|
||||||
|
|
||||||
func (store *WakuStore) Resume(ctx context.Context, pubsubTopic string, peerList []peer.ID) (int, error) {
|
func (store *WakuStore) Resume(ctx context.Context, pubsubTopic string, peerList []peer.ID) (int, error) {
|
||||||
currentTime := float64(time.Now().UnixNano())
|
currentTime := utils.GetUnixEpoch()
|
||||||
lastSeenTime := store.findLastSeen()
|
lastSeenTime := store.findLastSeen()
|
||||||
|
|
||||||
var offset float64 = 200000
|
var offset float64 = 200000
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func GetUnixEpoch() float64 {
|
||||||
|
return float64(time.Now().UnixNano()) / float64(time.Second)
|
||||||
|
}
|
Loading…
Reference in New Issue