github.com/holochain/holochain-proto@v0.1.0-alpha-26.0.20200915073418-5c83169c9b5b/action_makehash.go (about)

     1  // Copyright (C) 2013-2018, The MetaCurrency Project (Eric Harris-Braun, Arthur Brock, et. al.)
     2  // Use of this source code is governed by GPLv3 found in the LICENSE file
     3  //----------------------------------------------------------------------------------------
     4  //
     5  package holochain
     6  
     7  import (
     8  	. "github.com/holochain/holochain-proto/hash"
     9  )
    10  
    11  //------------------------------------------------------------
    12  // MakeHash
    13  
    14  type APIFnMakeHash struct {
    15  	entryType string
    16  	entry     Entry
    17  }
    18  
    19  func (a *APIFnMakeHash) Name() string {
    20  	return "makeHash"
    21  }
    22  
    23  func (a *APIFnMakeHash) Args() []Arg {
    24  	return []Arg{{Name: "entryType", Type: StringArg}, {Name: "entry", Type: EntryArg}}
    25  }
    26  
    27  func (a *APIFnMakeHash) Call(h *Holochain) (response interface{}, err error) {
    28  	var hash Hash
    29  	hash, err = a.entry.Sum(h.hashSpec)
    30  	if err != nil {
    31  		return
    32  	}
    33  	response = hash
    34  	return
    35  }