mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
436493350e
1. changes sentinel to use an http-like interface 2. moves hexutil, crypto/blake2b, metrics packages to erigon-lib
33 lines
733 B
Go
33 lines
733 B
Go
package freezer
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"github.com/ledgerwatch/erigon/cl/sentinel/communication/ssz_snappy"
|
|
|
|
"github.com/ledgerwatch/erigon-lib/types/ssz"
|
|
)
|
|
|
|
type marshalerHashable interface {
|
|
ssz.Marshaler
|
|
ssz.HashableSSZ
|
|
}
|
|
|
|
func PutObjectSSZIntoFreezer(objectName, freezerNamespace string, numericalId uint64, object marshalerHashable, record Freezer) error {
|
|
if record == nil {
|
|
return nil
|
|
}
|
|
buffer := new(bytes.Buffer)
|
|
if err := ssz_snappy.EncodeAndWrite(buffer, object); err != nil {
|
|
return err
|
|
}
|
|
id := fmt.Sprintf("%d", numericalId)
|
|
// put the hash of the object as the sidecar.
|
|
h, err := object.HashSSZ()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return record.Put(buffer, h[:], freezerNamespace, objectName, id)
|
|
}
|