quorum/core/types/common.go

57 lines
1.4 KiB
Go
Raw Normal View History

2015-07-06 17:54:22 -07:00
// Copyright 2014 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
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
)
type BlockProcessor interface {
Process(*Block) (state.Logs, Receipts, 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[:]
}