2017-10-23 15:56:29 +00:00
|
|
|
package core
|
|
|
|
|
2017-10-25 22:24:38 +00:00
|
|
|
import (
|
|
|
|
"math/big"
|
2017-10-23 15:56:29 +00:00
|
|
|
|
2017-10-25 22:24:38 +00:00
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
//Our block representation
|
2017-10-23 15:56:29 +00:00
|
|
|
type Block struct {
|
2017-10-23 20:02:56 +00:00
|
|
|
Number *big.Int
|
2017-10-25 22:24:38 +00:00
|
|
|
GasLimit *big.Int
|
|
|
|
GasUsed *big.Int
|
|
|
|
Time *big.Int
|
2017-10-23 20:02:56 +00:00
|
|
|
NumberOfTransactions int
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
2017-10-25 22:24:38 +00:00
|
|
|
|
|
|
|
//Geth Block to Ours
|
|
|
|
func GethBlockToCoreBlock(gethBlock *types.Block) Block {
|
|
|
|
return Block{
|
|
|
|
Number: gethBlock.Number(),
|
|
|
|
GasLimit: gethBlock.GasLimit(),
|
|
|
|
GasUsed: gethBlock.GasUsed(),
|
|
|
|
Time: gethBlock.Time(),
|
2017-10-27 20:47:13 +00:00
|
|
|
NumberOfTransactions: gethBlock.Transactions().Len(),
|
2017-10-25 22:24:38 +00:00
|
|
|
}
|
|
|
|
}
|