Merge pull request #603 from filecoin-project/feat/townhall-nonce
townhall: Send nonces
This commit is contained in:
commit
80b85d3bcf
@ -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++
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user