github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/swarm/storage/swarmhasher.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 19:16:45</date>
    10  //</624450121421033472>
    11  
    12  
    13  package storage
    14  
    15  import (
    16  	"hash"
    17  )
    18  
    19  const (
    20  	BMTHash     = "BMT"
    21  SHA3Hash    = "SHA3" //http://golang.org/pkg/hash/hash
    22  	DefaultHash = BMTHash
    23  )
    24  
    25  type SwarmHash interface {
    26  	hash.Hash
    27  	ResetWithLength([]byte)
    28  }
    29  
    30  type HashWithLength struct {
    31  	hash.Hash
    32  }
    33  
    34  func (h *HashWithLength) ResetWithLength(length []byte) {
    35  	h.Reset()
    36  	h.Write(length)
    37  }
    38