(native *native.NativeService, contract common.Address, authorizeInfo *AuthorizeInfo, preIfConsensus, ifConsensus bool, totalPos uint64, totalAmount uint64, peerAddress common.Address)
| 991 | } |
| 992 | |
| 993 | func executeAddressSplit(native *native.NativeService, contract common.Address, authorizeInfo *AuthorizeInfo, preIfConsensus, ifConsensus bool, totalPos uint64, totalAmount uint64, peerAddress common.Address) (uint64, error) { |
| 994 | var validatePos uint64 |
| 995 | if ifConsensus || preIfConsensus { |
| 996 | validatePos = authorizeInfo.ConsensusPos + authorizeInfo.WithdrawConsensusPos |
| 997 | } else { |
| 998 | validatePos = authorizeInfo.CandidatePos + authorizeInfo.WithdrawCandidatePos |
| 999 | } |
| 1000 | |
| 1001 | if validatePos == 0 || authorizeInfo.Address == peerAddress { |
| 1002 | return 0, nil |
| 1003 | } |
| 1004 | amount := validatePos * totalAmount / totalPos |
| 1005 | splitFeeAddress, err := getSplitFeeAddress(native, contract, authorizeInfo.Address) |
| 1006 | if err != nil { |
| 1007 | return 0, fmt.Errorf("getSplitFeeAddress, getSplitFeeAddress error: %v", err) |
| 1008 | } |
| 1009 | splitFeeAddress.Amount = splitFeeAddress.Amount + amount |
| 1010 | err = putSplitFeeAddress(native, contract, authorizeInfo.Address, splitFeeAddress) |
| 1011 | if err != nil { |
| 1012 | return 0, fmt.Errorf("putSplitFeeAddress, putSplitFeeAddress error: %v", err) |
| 1013 | } |
| 1014 | return amount, nil |
| 1015 | } |
| 1016 | |
| 1017 | func executePeerSplit(native *native.NativeService, contract common.Address, peerAddress common.Address, totalAmount uint64) error { |
| 1018 | splitFeeAddress, err := getSplitFeeAddress(native, contract, peerAddress) |
no test coverage detected