some small cleanup

This commit is contained in:
Jeromy 2020-04-14 15:13:52 -07:00
parent 0feab0aad4
commit 4e6839b5ef
4 changed files with 1 additions and 17 deletions

View File

@ -2,7 +2,6 @@ package drand
import (
"context"
"fmt"
"sync"
"time"
@ -118,7 +117,6 @@ func (db *DrandBeacon) handleStreamingUpdates() {
}
for e := range ch {
fmt.Println("Entry: ", e.Round, e.Signature)
db.cacheValue(types.BeaconEntry{
Round: e.Round,
Data: e.Signature,
@ -130,7 +128,7 @@ func (db *DrandBeacon) handleStreamingUpdates() {
}
func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Response {
fmt.Println("requesting drand entry: ", round)
// check cache, it it if there, otherwise query the endpoint
cres := db.getCachedValue(round)
if cres != nil {
out := make(chan beacon.Response, 1)
@ -142,7 +140,6 @@ func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Re
out := make(chan beacon.Response, 1)
go func() {
// check cache, it it if there, otherwise query the endpoint
resp, err := db.client.PublicRand(ctx, db.peers[0], &dproto.PublicRandRequest{Round: round})
var br beacon.Response
@ -196,13 +193,9 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr
}
func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {
fmt.Println("MAX BEACON ROUND FOR EPOCH: ", filEpoch)
fmt.Println("filecoin genesis time: ", db.filGenTime)
fmt.Println("drand genesis time: ", db.drandGenTime)
// TODO: sometimes the genesis time for filecoin is zero and this goes negative
latestTs := ((uint64(filEpoch) * db.filRoundTime) + db.filGenTime) - db.filRoundTime
dround := (latestTs - db.drandGenTime) / uint64(db.interval.Seconds())
fmt.Println("max beacon round will be: ", dround)
return dround
}

View File

@ -215,10 +215,6 @@ func NewGenerator() (*ChainGen, error) {
miners := []address.Address{maddr1, maddr2}
beac := beacon.NewMockBeacon(time.Second)
//beac, err := drand.NewDrandBeacon(tpl.Timestamp, build.BlockDelay)
//if err != nil {
//return nil, xerrors.Errorf("could not create beacon: %w", err)
//}
gen := &ChainGen{
bs: bs,

View File

@ -893,7 +893,6 @@ func (cs *ChainStore) TryFillTipSet(ts *types.TipSet) (*FullTipSet, error) {
}
func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) {
//log.Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar().Warnw("DrawRandomness", "base", rbase, "dsep", pers, "round", round, "entropy", entropy)
h := blake2b.New256()
if err := binary.Write(h, binary.BigEndian, int64(pers)); err != nil {
return nil, xerrors.Errorf("deriving randomness: %w", err)

View File

@ -2,7 +2,6 @@ package modules
import (
"context"
"fmt"
"net/http"
"reflect"
@ -384,8 +383,5 @@ func MinerRandomBeacon(api lapi.FullNode) (beacon.RandomBeacon, error) {
return nil, err
}
fmt.Println("Making miner random beacon: ", gents.Blocks()[0].Timestamp)
//return beacon.NewMockBeacon(build.BlockDelay * time.Second)
return drand.NewDrandBeacon(gents.Blocks()[0].Timestamp, build.BlockDelay)
}