From 4566fa8660894e150dcd844db10a077e32a860a7 Mon Sep 17 00:00:00 2001 From: adriamb Date: Fri, 11 May 2018 09:51:29 +0200 Subject: [PATCH] accounts/abi: fix comments --- accounts/abi/reflect.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/accounts/abi/reflect.go b/accounts/abi/reflect.go index 47912f7e56..6b8564714f 100644 --- a/accounts/abi/reflect.go +++ b/accounts/abi/reflect.go @@ -116,7 +116,7 @@ func requireUnpackKind(v reflect.Value, t reflect.Type, k reflect.Kind, // first round: for each Exportable field that contains a `abi:""` tag // and this field name exists in the arguments, pair them together. // second round: for each argument field that has not been already linked, -// find what variable is expected to be mapped into, if exists and has not been +// find what variable is expected to be mapped into, if it exists and has not been // used, pair them. func mapAbiToStructFields(args Arguments, value reflect.Value) (map[string]string, error) { @@ -134,14 +134,14 @@ func mapAbiToStructFields(args Arguments, value reflect.Value) (map[string]strin continue } - // skip fields that has not `abi:""` tag. + // skip fields that have no abi:"" tag. var ok bool var tagName string if tagName, ok = typ.Field(i).Tag.Lookup("abi"); !ok { continue } - // check if tag is emmpty. + // check if tag is empty. if tagName == "" { return nil, fmt.Errorf("struct: abi tag in '%s' is empty", structFieldName) } @@ -177,9 +177,11 @@ func mapAbiToStructFields(args Arguments, value reflect.Value) (map[string]strin return nil, fmt.Errorf("abi: purely underscored output cannot unpack to struct") } - // this abi been already paired, skip + // this abi has already been paired, skip... unless exists another not still assigned + // struct field with the same field name, in the case raise an error: + // abi: [ { "name": "value" } ] + // struct { Value *big.Int , Value1 *big.Int `abi:"value"`} if abi2struct[abiFieldName] != "" { - // unless if exists another not still assigned struct field with the same name if abi2struct[abiFieldName] != structFieldName && struct2abi[structFieldName] == "" && value.FieldByName(structFieldName).IsValid() { @@ -188,7 +190,7 @@ func mapAbiToStructFields(args Arguments, value reflect.Value) (map[string]strin continue } - // error if this struct field been already paired. + // return an error if this struct field has already been paired. if struct2abi[structFieldName] != "" { return nil, fmt.Errorf("abi: multiple outputs mapping to the same struct field '%s'", structFieldName) }