2014-11-18 07:58:22 -08:00
|
|
|
package types
|
|
|
|
|
2015-03-17 03:19:23 -07:00
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
2015-03-23 08:59:09 -07:00
|
|
|
"github.com/ethereum/go-ethereum/core/state"
|
2015-03-19 08:59:13 -07:00
|
|
|
|
|
|
|
"fmt"
|
2015-03-17 03:19:23 -07:00
|
|
|
)
|
2014-11-18 07:58:22 -08:00
|
|
|
|
|
|
|
type BlockProcessor interface {
|
2015-03-19 08:19:54 -07:00
|
|
|
Process(*Block) (*big.Int, state.Logs, error)
|
2014-11-18 07:58:22 -08:00
|
|
|
}
|
2015-03-16 09:27:23 -07:00
|
|
|
|
2015-03-17 10:00:03 -07:00
|
|
|
const bloomLength = 256
|
|
|
|
|
|
|
|
type Bloom [bloomLength]byte
|
2015-03-16 09:27:23 -07:00
|
|
|
|
|
|
|
func BytesToBloom(b []byte) Bloom {
|
|
|
|
var bloom Bloom
|
|
|
|
bloom.SetBytes(b)
|
|
|
|
return bloom
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *Bloom) SetBytes(d []byte) {
|
2015-03-17 10:00:03 -07:00
|
|
|
if len(b) < len(d) {
|
|
|
|
panic(fmt.Sprintf("bloom bytes too big %d %d", len(b), len(d)))
|
2015-03-16 09:27:23 -07:00
|
|
|
}
|
|
|
|
|
2015-03-19 15:20:41 -07:00
|
|
|
copy(b[bloomLength-len(d):], d)
|
2015-03-16 09:27:23 -07:00
|
|
|
}
|
2015-03-17 03:19:23 -07:00
|
|
|
|
|
|
|
func (b Bloom) Big() *big.Int {
|
|
|
|
return common.Bytes2Big(b[:])
|
|
|
|
}
|
2015-03-18 03:44:25 -07:00
|
|
|
|
|
|
|
func (b Bloom) Bytes() []byte {
|
|
|
|
return b[:]
|
|
|
|
}
|