-
Notifications
You must be signed in to change notification settings - Fork 0
/
preimages.go
executable file
·35 lines (29 loc) · 899 Bytes
/
preimages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package rpc
import (
"context"
"github.com/zennittians/intelchain/core"
"github.com/zennittians/intelchain/eth/rpc"
"github.com/zennittians/intelchain/itc"
)
type PreimagesService struct {
itc *itc.Intelchain
}
// NewPreimagesAPI creates a new API for the RPC interface
func NewPreimagesAPI(itc *itc.Intelchain, version string) rpc.API {
var service interface{} = &PreimagesService{itc}
return rpc.API{
Namespace: version,
Version: APIVersion,
Service: service,
Public: true,
}
}
func (s *PreimagesService) Export(ctx context.Context, path string) error {
// these are by default not blocking
return core.ExportPreimages(s.itc.BlockChain, path)
}
func (s *PreimagesService) Verify(ctx context.Context) (uint64, error) {
currentBlock := s.itc.CurrentBlock()
// these are by default not blocking
return core.VerifyPreimages(currentBlock.Header(), s.itc.BlockChain)
}