SPV Module Integration
The Elastos sidechain needs to integrate the SPV module, which is used to obtain MerkleBlock of current mainchain and verify the consensus of the sidechain. The information obtained through SPV module, which is mainly block header information and cross-chain recharge transaction - these can support the configuration of different transaction categories obtained by BloomFilter extension.
Code example:
1
genesisAddress, err := programHash.ToAddress()
2
if err != nil {
3
eladlog.Fatalf("Genesis program hash to address failed, %s", err)
4
os.Exit(1)
5
}
6
7
spvCfg := spv.Config{
8
DataDir: filepath.Join(DataPath, DataDir, SpvDir),
9
ChainParams: spvNetParams,
10
PermanentPeers: cfg.SPVPermanentPeers,
11
GenesisAddress: genesisAddress,
12
FilterType: filter.FTCustomID,
13
NodeVersion: nodePrefix + Version,
14
}
15
spvService, err := spv.NewService(&spvCfg)
16
if err != nil {
17
eladlog.Fatalf("SPV module initialize failed, %s", err)
18
os.Exit(1)
19
}
20
21
defer spvService.Stop()
22
spvService.Start()
Copied!
Copy link