Set timestamp in miner

This commit is contained in:
Łukasz Magiera 2019-09-06 19:44:09 +02:00
parent 7450d995e2
commit 314141e4ea
3 changed files with 8 additions and 7 deletions

View File

@ -2,12 +2,11 @@ package gen
import (
"context"
bls "github.com/filecoin-project/go-bls-sigs"
cid "github.com/ipfs/go-cid"
hamt "github.com/ipfs/go-hamt-ipld"
"github.com/filecoin-project/go-bls-sigs"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
"github.com/pkg/errors"
sharray "github.com/whyrusleeping/sharray"
"github.com/whyrusleeping/sharray"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-lotus/chain/actors"

View File

@ -440,7 +440,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
if h.Timestamp < baseTs.MinTimestamp()+uint64(build.BlockDelay*len(h.Tickets)) {
log.Warn("timestamp funtimes: ", h.Timestamp, baseTs.MinTimestamp(), len(h.Tickets))
return xerrors.Errorf("block was generated too soon (timestamp < BLOCK_DELAY * len(tickets))")
return xerrors.Errorf("block was generated too soon (h.ts:%d < base.mints:%d + BLOCK_DELAY:%d * tkts.len:%d)", h.Timestamp, baseTs.MinTimestamp(), build.BlockDelay, len(h.Tickets))
}
if err := syncer.minerIsValid(ctx, h.Miner, baseTs); err != nil {

View File

@ -336,8 +336,10 @@ func (m *Miner) createBlock(base *MiningBase, ticket *types.Ticket, proof types.
msgs := m.selectMessages(pending)
uts := time.Now().Unix() // TODO: review: is this what we want here?
// why even return this? that api call could just submit it for us
return m.api.MinerCreateBlock(context.TODO(), m.addresses[0], base.ts, append(base.tickets, ticket), proof, msgs, 0)
return m.api.MinerCreateBlock(context.TODO(), m.addresses[0], base.ts, append(base.tickets, ticket), proof, msgs, uint64(uts))
}
func (m *Miner) selectMessages(msgs []*types.SignedMessage) []*types.SignedMessage {