fixing compilation errors

This commit is contained in:
cwaldron97 2019-06-21 15:40:39 -05:00
parent 67683a7131
commit bea1cd04fb
3 changed files with 9 additions and 8 deletions

View file

@ -21,7 +21,7 @@ object GCS {
*/
def buildGCS(
data: Vector[ByteVector],
key: ByteVector,
key: SipHashKey,
p: UInt8,
m: UInt64): BitVector = {
val hashedValues = hashedSetConstruct(data, key, m)
@ -34,7 +34,7 @@ object GCS {
*/
def buildGolombFilter(
data: Vector[ByteVector],
key: ByteVector,
key: SipHashKey,
p: UInt8,
m: UInt64): GolombFilter = {
val encodedData = buildGCS(data, key, p, m)
@ -48,14 +48,14 @@ object GCS {
*/
def buildBasicBlockFilter(
data: Vector[ByteVector],
key: ByteVector): GolombFilter = {
key: SipHashKey): GolombFilter = {
buildGolombFilter(data, key, BlockFilter.P, BlockFilter.M)
}
//item remains bytevector key to be changed create new file in GCS folder that redefines sipkeyhash
//will probably have a require statement bytevector length of 16 bytes or 128 bits. Add a couple methods
//to turn the key into an array of bytes (look to toArray method on line 65)
private def sipHash(item: ByteVector, key: ByteVector): UInt64 = {
private def sipHash(item: ByteVector, key: SipHashKey): UInt64 = {
// https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki#hashing-data-objects
val sipHashCParam = 2
val sipHashDParam = 4
@ -79,7 +79,7 @@ object GCS {
* Hashes the item to the range [0, f)
* @see [[https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki#hashing-data-objects]]
*/
def hashToRange(item: ByteVector, f: UInt64, key: ByteVector): UInt64 = {
def hashToRange(item: ByteVector, f: UInt64, key: SipHashKey): UInt64 = {
val hash = sipHash(item, key)
val bigInt = (hash.toBigInt * f.toBigInt) >> 64
@ -93,7 +93,7 @@ object GCS {
*/
def hashedSetConstruct(
rawItems: Vector[ByteVector],
key: ByteVector,
key: SipHashKey,
m: UInt64): Vector[UInt64] = {
val n = rawItems.length
val f = m * n

View file

@ -24,7 +24,7 @@ import scala.annotation.tailrec
* TODO: Replace ByteVector with a type for keys
*/
case class GolombFilter(
key: ByteVector,
key: SipHashKey,
m: UInt64,
p: UInt8,
n: CompactSizeUInt,
@ -149,7 +149,7 @@ object BlockFilter {
def apply(
block: Block,
prevOutputScripts: Vector[ScriptPubKey]): GolombFilter = {
val key = block.blockHeader.hash.bytes.take(16)
val key: SipHashKey = block.blockHeader.hash.bytes.take(16)
val newScriptPubKeys: Vector[ByteVector] =
getOutputScriptPubKeysFromBlock(block).map(_.asmBytes)

View file

@ -1,3 +1,4 @@
package org.bitcoins.core.gcs
import scodec.bits.ByteVector
case class SipHashKey(bytes: ByteVector) {
require(