mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
- Update github.com/luxfi/vm v1.0.1 → v1.0.2 - Remove local replace directive for vm - Use published package versions for reproducible builds
36 lines
948 B
Go
36 lines
948 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
package atomic
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/luxfi/coreth/plugin/evm/message"
|
|
"github.com/luxfi/crypto"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
var _ message.SyncableParser = (*summaryParser)(nil)
|
|
|
|
type summaryParser struct{}
|
|
|
|
func NewSummaryParser() *summaryParser {
|
|
return &summaryParser{}
|
|
}
|
|
|
|
func (a *summaryParser) Parse(summaryBytes []byte, acceptImpl message.AcceptImplFn) (message.Syncable, error) {
|
|
summary := Summary{}
|
|
if _, err := message.Codec.Unmarshal(summaryBytes, &summary); err != nil {
|
|
return nil, fmt.Errorf("failed to parse syncable summary: %w", err)
|
|
}
|
|
|
|
summary.bytes = summaryBytes
|
|
summaryID, err := ids.ToID(crypto.Keccak256(summaryBytes))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to compute summary ID: %w", err)
|
|
}
|
|
summary.summaryID = summaryID
|
|
summary.acceptImpl = acceptImpl
|
|
return &summary, nil
|
|
}
|