quorum/core/types/common.go

41 lines
635 B
Go
Raw Normal View History

package types
2015-03-17 03:19:23 -07:00
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
2015-03-19 15:20:41 -07:00
"github.com/ethereum/go-ethereum/state"
2015-03-19 08:59:13 -07:00
"fmt"
2015-03-17 03:19:23 -07:00
)
type BlockProcessor interface {
2015-03-19 08:19:54 -07:00
Process(*Block) (*big.Int, state.Logs, error)
}
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[:]
}