github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/execution/engine/blockchain.go (about) 1 package engine 2 3 import ( 4 "encoding/binary" 5 "time" 6 7 "github.com/hyperledger/burrow/execution/errors" 8 ) 9 10 type TestBlockchain struct { 11 BlockHeight uint64 12 BlockTime time.Time 13 } 14 15 var _ Blockchain = (*TestBlockchain)(nil) 16 17 func (b *TestBlockchain) LastBlockHeight() uint64 { 18 return b.BlockHeight 19 } 20 21 func (b *TestBlockchain) LastBlockTime() time.Time { 22 return b.BlockTime 23 } 24 25 func (b *TestBlockchain) BlockHash(height uint64) ([]byte, error) { 26 if height > b.BlockHeight { 27 return nil, errors.Codes.InvalidBlockNumber 28 } 29 bs := make([]byte, 32) 30 binary.BigEndian.PutUint64(bs[24:], height) 31 return bs, nil 32 } 33 34 func (V *TestBlockchain) ChainID() string { 35 return "TestChain" 36 }