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