plugeth/core/types/common.go

41 lines
640 B
Go
Raw Normal View History

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