MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / fillTxNonce

Function fillTxNonce

cmd/cql/internal/rpc.go:295–324  ·  view source on GitHub ↗
(tx pi.Transaction)

Source from the content-addressed store, hash-verified

293}
294
295func fillTxNonce(tx pi.Transaction) (err error) {
296 _, err = nestedWalkFillTxNonce(reflect.ValueOf(tx), "", func(fieldPath string, rv reflect.Value) (err error) {
297 var (
298 pubKey *asymmetric.PublicKey
299 accountAddr proto.AccountAddress
300 )
301 if pubKey, err = kms.GetLocalPublicKey(); err != nil {
302 return
303 }
304 if accountAddr, err = crypto.PubKeyHash(pubKey); err != nil {
305 return
306 }
307 nonceReq := &types.NextAccountNonceReq{
308 Addr: accountAddr,
309 }
310 nonceResp := &types.NextAccountNonceResp{}
311 if err = rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint),
312 route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
313 return
314 }
315
316 rv.SetUint(uint64(nonceResp.Nonce))
317 ConsoleLog.Infof("filled tx type %s nonce field %s with nonce %d",
318 tx.GetTransactionType().String(), fieldPath, nonceResp.Nonce)
319
320 return
321 })
322
323 return
324}
325
326func resolveRPCEntities() (req interface{}, resp interface{}) {
327 rpcParts := strings.SplitN(rpcName, ".", 2)

Callers 1

runRPCFunction · 0.85

Calls 8

GetLocalPublicKeyFunction · 0.92
PubKeyHashFunction · 0.92
NodeIDTypeAlias · 0.92
nestedWalkFillTxNonceFunction · 0.85
CallNodeMethod · 0.80
InfofMethod · 0.80
GetTransactionTypeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected