aboutsummaryrefslogblamecommitdiffstats
path: root/core/types/common.go
blob: 4397d4938e10b113867429f395838f469d9e9db9 (plain) (tree)
1
2
3
4
5
6
7
8
9

             



                                                
                                                    

             
 

                               
                                                     
 
 


                            







                                    

                                                                               

         
                                       
 



                                     



                               
package types

import (
    "math/big"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/core/state"

    "fmt"
)

type BlockProcessor interface {
    Process(*Block) (*big.Int, state.Logs, error)
}

const bloomLength = 256

type Bloom [bloomLength]byte

func BytesToBloom(b []byte) Bloom {
    var bloom Bloom
    bloom.SetBytes(b)
    return bloom
}

func (b *Bloom) SetBytes(d []byte) {
    if len(b) < len(d) {
        panic(fmt.Sprintf("bloom bytes too big %d %d", len(b), len(d)))
    }

    copy(b[bloomLength-len(d):], d)
}

func (b Bloom) Big() *big.Int {
    return common.Bytes2Big(b[:])
}

func (b Bloom) Bytes() []byte {
    return b[:]
}