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"
|
|
|
|
)
|
|
|
|
|
2017-10-23 15:56:29 +00:00
|
|
|
type Block struct {
|
2017-10-31 13:58:04 +00:00
|
|
|
Number *big.Int
|
|
|
|
GasLimit *big.Int
|
|
|
|
GasUsed *big.Int
|
|
|
|
Time *big.Int
|
|
|
|
Transactions []Transaction
|
2017-10-23 15:56:29 +00:00
|
|
|
}
|
2017-10-25 22:24:38 +00:00
|
|
|
|
|
|
|
func GethBlockToCoreBlock(gethBlock *types.Block) Block {
|
2017-10-31 13:58:04 +00:00
|
|
|
transactions := []Transaction{}
|
|
|
|
for _, gethTransaction := range gethBlock.Transactions() {
|
|
|
|
transactions = append(transactions, gethTransToCoreTrans(gethTransaction))
|
|
|
|
}
|
2017-10-25 22:24:38 +00:00
|
|
|
return Block{
|
2017-10-31 13:58:04 +00:00
|
|
|
Number: gethBlock.Number(),
|
|
|
|
GasLimit: gethBlock.GasLimit(),
|
|
|
|
GasUsed: gethBlock.GasUsed(),
|
|
|
|
Time: gethBlock.Time(),
|
|
|
|
Transactions: transactions,
|
2017-10-25 22:24:38 +00:00
|
|
|
}
|
|
|
|
}
|