Merge pull request #603 from filecoin-project/feat/townhall-nonce

townhall: Send nonces
This commit is contained in:
Łukasz Magiera 2019-11-14 17:42:32 +01:00 committed by GitHub
commit 80b85d3bcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,6 +71,7 @@ type message struct {
Height uint64
Weight types.BigInt
Time uint64
Nonce uint64
// Meta
@ -86,6 +87,9 @@ func sendHeadNotifs(ctx context.Context, ps *pubsub.PubSub, topic string, chain
return err
}
// using unix nano time makes very sure we pick a nonce higher than previous restart
nonce := uint64(time.Now().UnixNano())
for {
select {
case notif := <-notifs:
@ -103,6 +107,7 @@ func sendHeadNotifs(ctx context.Context, ps *pubsub.PubSub, topic string, chain
Weight: w,
NodeName: nickname,
Time: uint64(time.Now().UnixNano() / 1000_000),
Nonce: nonce,
}
b, err := json.Marshal(m)
@ -116,5 +121,7 @@ func sendHeadNotifs(ctx context.Context, ps *pubsub.PubSub, topic string, chain
case <-ctx.Done():
return nil
}
nonce++
}
}